Module: Mongoid::Extensions::Float::ClassMethods
- Defined in:
- lib/mongoid/extensions/float.rb
Instance Method Summary collapse
-
#mongoize(object) ⇒ Float | nil
(also: #demongoize)
Turn the object from the ruby type we deal with to a Mongo friendly type.
Instance Method Details
#mongoize(object) ⇒ Float | nil Also known as: demongoize
Turn the object from the ruby type we deal with to a Mongo friendly type.
37 38 39 40 41 42 43 44 45 |
# File 'lib/mongoid/extensions/float.rb', line 37 def mongoize(object) return if object.blank? if object.is_a?(String) object.to_f if object.numeric? else object.try(:to_f) end end |