module Mongoid::Extensions::BigDecimal

Adds type-casting behavior to BigDecimal class.

Public Class Methods

included(base) click to toggle source

Behavior to be invoked when the module is included.

@param [ Module ] base the class or module doing the including

@api private

# File lib/mongoid/extensions/big_decimal.rb, line 13
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

__to_inc__() click to toggle source

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

@example Convert the big decimal.

bd.__to_inc__

@return [ Float ] The big decimal as a float. @deprecated

# File lib/mongoid/extensions/big_decimal.rb, line 24
def __to_inc__
  to_f
end
mongoize() click to toggle source

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

@example Mongoize the object.

object.mongoize

@return [ String | BSON::Decimal128 | nil ] The object or nil.

# File lib/mongoid/extensions/big_decimal.rb, line 36
def mongoize
  ::BigDecimal.mongoize(self)
end
numeric?() click to toggle source

Is the BigDecimal a number?

@example Is the object a number?.

object.numeric?

@return [ true ] Always true.

# File lib/mongoid/extensions/big_decimal.rb, line 46
def numeric?
  true
end