Module: Mongoid::Extensions::Integer::ClassMethods
- Defined in:
- lib/mongoid/extensions/integer.rb
Instance Method Summary collapse
-
#mongoize(object) ⇒ Integer | nil
(also: #demongoize)
Turn the object from the ruby type we deal with to a Mongo friendly type.
Instance Method Details
#mongoize(object) ⇒ Integer | nil Also known as: demongoize
Turn the object from the ruby type we deal with to a Mongo friendly type.
47 48 49 50 51 52 53 54 55 |
# File 'lib/mongoid/extensions/integer.rb', line 47 def mongoize(object) return if object.blank? if object.is_a?(String) object.to_i if object.numeric? else object.try(:to_i) end end |