lib/mongoid/extensions/big_decimal.rb
# Mongoize an object of any type to how it's stored in the db.
#
# @example Mongoize the object.
#   BigDecimal.mongoize(123)
#
# @param [ Object ] object The object to Mongoize
#
# @return [ String | BSON::Decimal128 | nil ] A String or Decimal128
#   representing the object or nil.
Mongoize an object of any type to how it's stored in the db.
Mongoize an object of any type to how it ' s stored in the db .
def mongoize(object)
          unless object.nil?
            if object.is_a?(BSON::Decimal128)
              object
            elsif Mongoid.map_big_decimal_to_decimal128
              if object.is_a?(BigDecimal)
                BSON::Decimal128.new(object)
              elsif object.numeric?
                BSON::Decimal128.new(object.to_s)
              else
                object.mongoize
              end
            elsif object.numeric?
              object.to_s
            end
          end
        end
def mongoize ( object ) unless object . nil? if object . is_a? ( BSON :: Decimal128 ) object elsif Mongoid . map_big_decimal_to_decimal128 if object . is_a? ( BigDecimal ) BSON :: Decimal128 . new ( object ) elsif object . numeric? BSON :: Decimal128 . new ( object . to_s ) else object . mongoize end elsif object . numeric? object . to_s end end end
Mongoize an object of any type to how it's stored in the db.
Mongoize an object of any type to how it ' s stored in the db .
A String or Decimal128 representing the object or nil.
A String or Decimal128 representing the object or nil .
 String | BSON::Decimal128 | nil 
object
<not_specific>
<not_specific>
object The object to Mongoize
object The object to Mongoize
example
Mongoize the object. BigDecimal.mongoize(123)
Mongoize the object . BigDecimal . mongoize ( 123 )