Module: Mongoid::Extensions::Integer::ClassMethods

Defined in:
build/mongoid-master/lib/mongoid/extensions/integer.rb

Instance Method Summary collapse

Instance Method Details

#mongoize(object) ⇒ String Also known as: demongoize

Turn the object from the ruby type we deal with to a Mongo friendly type.

Examples:

Mongoize the object.

BigDecimal.mongoize("123.11")

Returns:

  • (String)

    The object mongoized.

Since:

  • 3.0.0



55
56
57
58
59
60
61
# File 'build/mongoid-master/lib/mongoid/extensions/integer.rb', line 55

def mongoize(object)
  unless object.blank?
    __numeric__(object).to_i rescue 0
  else
    nil
  end
end