Method: Attribution::ClassMethods#decimal

Defined in:
lib/attribution.rb

#decimal(attr, metadata = {}) ⇒ Object

Defines a decimal attribute

Parameters:

  • attr (Symbol)

    The name of the attribute

  • metadata (Hash{Symbol => Object}) (defaults to: {})

    The metadata for the attribute



140
141
142
143
144
145
# File 'lib/attribution.rb', line 140

def decimal(attr, ={})
  add_attribute(attr, :decimal, )
  define_method("#{attr}=") do |arg|
    instance_variable_set("@#{attr}", arg.nil? ? nil : BigDecimal.new(arg.to_s))
  end
end