Module: Mongoid::Criteria::Queryable::Extensions::BigDecimal::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#evolve(object) ⇒ String

Evolves the big decimal into a MongoDB friendly value - in this case a string.

Examples:

Evolve the big decimal

BigDecimal.evolve(decimal)

Parameters:

Returns:

  • (String)

    The big decimal as a string.



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'build/mongoid-master/lib/mongoid/criteria/queryable/extensions/big_decimal.rb', line 24

def evolve(object)
  __evolve__(object) do |obj|
    if obj
      if obj.is_a?(::BigDecimal) && Mongoid.map_big_decimal_to_decimal128
        BSON::Decimal128.new(obj)
      elsif obj.is_a?(BSON::Decimal128)
        obj
      else
        obj.to_s
      end
    end
  end
end