Class: DataMapper::Property::DecimalArray

Inherits:
PgArray
  • Object
show all
Defined in:
lib/dm-pg-types/decimal_array.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PgArray

#dump

Constructor Details

#initialize(model, name, options = {}) ⇒ DecimalArray

Returns a new instance of DecimalArray.



9
10
11
12
13
14
15
16
17
# File 'lib/dm-pg-types/decimal_array.rb', line 9

def initialize(model, name, options = {})
  super
  @precision = @options[:precision] || 10
  @scale     = @options[:scale]     || 0

  unless @precision > 0
    raise ArgumentError, "precision must be greater than 0, but was #{@precision.inspect}"
  end
end

Instance Attribute Details

#maxObject (readonly)

Returns the value of attribute max.



7
8
9
# File 'lib/dm-pg-types/decimal_array.rb', line 7

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



7
8
9
# File 'lib/dm-pg-types/decimal_array.rb', line 7

def min
  @min
end

#precisionObject (readonly)

Returns the value of attribute precision.



7
8
9
# File 'lib/dm-pg-types/decimal_array.rb', line 7

def precision
  @precision
end

#scaleObject (readonly)

Returns the value of attribute scale.



7
8
9
# File 'lib/dm-pg-types/decimal_array.rb', line 7

def scale
  @scale
end

Instance Method Details

#load(value) ⇒ Object



20
21
22
# File 'lib/dm-pg-types/decimal_array.rb', line 20

def load(value)
  super.map(&:to_f) if value
end