module Mongoid::Extensions::BigDecimal::ClassMethods

Public Instance Methods

demongoize(object) click to toggle source

Convert the object from its mongo friendly ruby type to this type.

@example Demongoize the object.

Object.demongoize(object)

@param [ Object ] object The object to demongoize.

@return [ BigDecimal, nil ] A BigDecimal derived from the object or nil.

@since 3.0.0

# File lib/mongoid/extensions/big_decimal.rb, line 57
def demongoize(object)
  object && object.numeric? ? BigDecimal(object.to_s) : nil
end
mongoize(object) click to toggle source

Mongoize an object of any type to how it’s stored in the db as a String.

@example Mongoize the object.

BigDecimal.mongoize(123)

@param [ Object ] object The object to Mongoize

@return [ String, nil ] A String representing the object or nil.

@since 3.0.7

# File lib/mongoid/extensions/big_decimal.rb, line 71
def mongoize(object)
  object && object.numeric? ? object.to_s : nil
end