Module: Mongoid::Extensions::Float::ClassMethods

Defined in:
build/mongoid-7.3/lib/mongoid/extensions/float.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.

Float.mongoize("123.11")

Parameters:

  • object (Object)

    The object to mongoize.

Returns:

  • (String)

    The object mongoized.

Since:

  • 3.0.0



45
46
47
48
49
50
51
# File 'build/mongoid-7.3/lib/mongoid/extensions/float.rb', line 45

def mongoize(object)
  unless object.blank?
    __numeric__(object).to_f rescue 0.0
  else
    nil
  end
end