module Mongoid::Extensions::Integer::ClassMethods

Public Instance Methods

demongoize(object)
Alias for: mongoize
mongoize(object) click to toggle source

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

@example Mongoize the object.

BigDecimal.mongoize("123.11")

@return [ Integer | nil ] The object mongoized or nil.

# File lib/mongoid/extensions/integer.rb, line 51
def mongoize(object)
  return if object.blank?
  if object.is_a?(String)
    if object.numeric?
      object.to_i
    end
  else
    object.try(:to_i)
  end
end
Also aliased as: demongoize