Methods

Included Modules

Class Index [+]

Quicksearch

DataMapper::Property::Numeric

Constants

DEFAULT_NUMERIC_MIN
DEFAULT_NUMERIC_MAX

Attributes

precision[R]
scale[R]
min[R]
max[R]

Public Class Methods

new(model, name, options = {}) click to toggle source
    # File lib/dm-core/property/numeric.rb, line 15
15:       def initialize(model, name, options = {})
16:         super
17: 
18:         if @primitive == BigDecimal || @primitive == ::Float
19:           @precision = @options.fetch(:precision)
20:           @scale     = @options.fetch(:scale)
21: 
22:           unless @precision > 0
23:             raise ArgumentError, "precision must be greater than 0, but was #{@precision.inspect}"
24:           end
25:         end
26: 
27:         if @options.key?(:min) || @options.key?(:max)
28:           @min = @options.fetch(:min, self.class::DEFAULT_NUMERIC_MIN)
29:           @max = @options.fetch(:max, self.class::DEFAULT_NUMERIC_MAX)
30: 
31:           if @max < DEFAULT_NUMERIC_MIN && !@options.key?(:min)
32:             raise ArgumentError, "min should be specified when the max is less than #{DEFAULT_NUMERIC_MIN}"
33:           elsif @max < @min
34:             raise ArgumentError, "max must be less than the min, but was #{@max} while the min was #{@min}"
35:           end
36:         end
37:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.