Method: DataMapper::Property::Decimal#initialize
- Defined in:
- lib/dm-core/property/decimal.rb
#initialize(model, name, options = {}) ⇒ Decimal (protected)
Returns a new instance of Decimal.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dm-core/property/decimal.rb', line 10 def initialize(model, name, = {}) super [ :scale, :precision ].each do |key| unless .key?(key) warn "options[#{key.inspect}] should be set for #{self.class}, defaulting to #{send(key).inspect}" end end unless @scale >= 0 raise ArgumentError, "scale must be equal to or greater than 0, but was #{@scale.inspect}" end unless @precision >= @scale raise ArgumentError, "precision must be equal to or greater than scale, but was #{@precision.inspect} and scale was #{@scale.inspect}" end end |