Module: Mongoid::Criteria::Queryable::Extensions::Numeric::ClassMethods
Relationships & Source Files | |
Defined in: | lib/mongoid/criteria/queryable/extensions/numeric.rb |
Instance Method Summary
-
#__numeric__(object) ⇒ Object
Internal use only
Internal use only
Get the object as a numeric.
-
#evolve(object) ⇒ Integer
Evolve the object to an integer.
Instance Method Details
#__numeric__(object) ⇒ Object
This method is for internal use only.
Get the object as a numeric.
# File 'lib/mongoid/criteria/queryable/extensions/numeric.rb', line 46
def __numeric__(object) object.to_s.match?(/\A[-+]?[0-9]*[0-9.]0*\z/) ? object.to_i : Float(object) end
#evolve(object) ⇒ Integer
Evolve the object to an integer.
# File 'lib/mongoid/criteria/queryable/extensions/numeric.rb', line 58
def evolve(object) __evolve__(object) do |obj| __numeric__(obj) rescue obj end end