Sha256: e71b2e4a1f8c84d8eafb540939e88d3707950fc7dff10c9b6bd4639482657df4
Contents?: true
Size: 1 KB
Versions: 15
Compression:
Stored size: 1 KB
Contents
require 'bigdecimal' module Ardm class Property class Decimal < Numeric load_as BigDecimal dump_as BigDecimal coercion_method :to_decimal DEFAULT_PRECISION = 10 DEFAULT_SCALE = 0 precision(DEFAULT_PRECISION) scale(DEFAULT_SCALE) protected def initialize(model, name, options = {}) super [ :scale, :precision ].each do |key| unless @options.key?(key) warn "options[#{key.inspect}] should be set for #{self.class}, defaulting to #{send(key).inspect} (#{caller.first})" 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 end # class Decimal end # class Property end # module Ardm
Version data entries
15 entries across 15 versions & 1 rubygems