No commit activity in last 3 years
No release in over 3 years
Mongoid type which stores BigDecimals as Integers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

Mongoid::BigDecimalInteger Build Status

Mongoid type which stores BigDecimals as Integers.

The default BigDecimal type provided in Mongoid stores BigDecimals as Strings. Because of this, stuff like sorts and range queries don't work. This type multiplies the value by a (configurable) power of 10 and stores the resulting Integer.

Installation

Add this line to your application's Gemfile:

gem 'mongoid_big_decimal_integer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mongoid_big_decimal_integer

Configuration

By default, Mongoid::BigDecimalInteger uses 2 decimal places (which means that a value is multiplied by 10^2 before being stored). You can change this by calling:

Mongoid::BigDecimalInteger.decimal_places = 12

Usage

field :my_field, type: Mongoid::BigDecimalInteger

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request