Module: Mongoid::Extensions::BigDecimal

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

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#__to_inc__Float

Convert the big decimal to an $inc-able value.

Examples:

Convert the big decimal.

bd.__to_inc__

Returns:

  • (Float)

    The big decimal as a float.



13
14
15
# File 'build/mongoid-master/lib/mongoid/extensions/big_decimal.rb', line 13

def __to_inc__
  to_f
end

#mongoizeObject

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

Examples:

Mongoize the object.

object.mongoize

Returns:



24
25
26
27
28
29
30
# File 'build/mongoid-master/lib/mongoid/extensions/big_decimal.rb', line 24

def mongoize
  if Mongoid.map_big_decimal_to_decimal128
    BSON::Decimal128.new(self)
  else
    to_s
  end
end

#numeric?true

Is the BigDecimal a number?

Examples:

Is the object a number?.

object.numeric?

Returns:

  • (true)

    Always true.



38
39
40
# File 'build/mongoid-master/lib/mongoid/extensions/big_decimal.rb', line 38

def numeric?
  true
end