Class: MLS::Property::Decimal

Inherits:
MLS::Property show all
Defined in:
lib/mls/properties/decimal.rb

Constant Summary

Constants inherited from MLS::Property

DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from MLS::Property

#default, #instance_variable_name, #model, #name, #options, #reader_visibility, #writer_visibility

Instance Method Summary collapse

Methods inherited from MLS::Property

demodulized_names, determine_class, #determine_visibility, find_class, inherited, #initialize, #set_default_value

Constructor Details

This class inherits a constructor from MLS::Property

Instance Method Details

#dump(value) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/mls/properties/decimal.rb', line 13

def dump(value)
  if value.is_a?(BigDecimal)
    value.to_s
  else
    value
  end
end

#load(value) ⇒ Object

from_json



3
4
5
6
7
8
9
10
11
# File 'lib/mls/properties/decimal.rb', line 3

def load(value) # from_json
  if value.nil?
	nil
elsif value.is_a?(BigDecimal)
    value
  else
    BigDecimal.new(value.to_s)
  end
end