Module: Mongoid::Extensions::BigDecimal::ClassMethods
- Defined in:
- lib/mongoid/extensions/big_decimal.rb
Instance Method Summary collapse
-
#demongoize(object) ⇒ Object
Convert the object from its mongo friendly ruby type to this type.
-
#mongoize(object) ⇒ String
Mongoize an object of any type to how it’s stored in the db as a big decimal.
Instance Method Details
#demongoize(object) ⇒ Object
Convert the object from its mongo friendly ruby type to this type.
43 44 45 46 47 |
# File 'lib/mongoid/extensions/big_decimal.rb', line 43 def demongoize(object) if object object.numeric? ? ::BigDecimal.new(object.to_s) : object end end |
#mongoize(object) ⇒ String
Mongoize an object of any type to how it’s stored in the db as a big decimal.
60 61 62 |
# File 'lib/mongoid/extensions/big_decimal.rb', line 60 def mongoize(object) object ? object.to_s : object end |