Class: DataMapper::Property::DecimalArray
- Defined in:
- lib/dm-pg-types/decimal_array.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#precision ⇒ Object
readonly
Returns the value of attribute precision.
-
#scale ⇒ Object
readonly
Returns the value of attribute scale.
Instance Method Summary collapse
-
#initialize(model, name, options = {}) ⇒ DecimalArray
constructor
A new instance of DecimalArray.
- #load(value) ⇒ Object
Methods inherited from PgArray
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, = {}) 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
#max ⇒ Object (readonly)
Returns the value of attribute max.
7 8 9 |
# File 'lib/dm-pg-types/decimal_array.rb', line 7 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
7 8 9 |
# File 'lib/dm-pg-types/decimal_array.rb', line 7 def min @min end |
#precision ⇒ Object (readonly)
Returns the value of attribute precision.
7 8 9 |
# File 'lib/dm-pg-types/decimal_array.rb', line 7 def precision @precision end |
#scale ⇒ Object (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 |