class DataMapper::Property::PgNumericArray

Attributes

precision[R]
scale[R]

Public Class Methods

new(model, name, options = {}) click to toggle source
Calls superclass method
# File lib/dm-postgres-types/property/pg_numeric_array.rb, line 12
def initialize(model, name, options = {})
  super
  @precision = @options[:precision] || 10
  @scale     = @options[:scale]     || 0

  if precision <= 0
    raise ArgumentError, "precision must be greater than 0"
  end

  if scale < 0
    raise ArgumentError, "scale must be greater than or equal to 0"
  end        
end

Public Instance Methods

load(value) click to toggle source
Calls superclass method DataMapper::Property::PgArray#load
# File lib/dm-postgres-types/property/pg_numeric_array.rb, line 26
def load(value)
  values = super
  values.map! { |val| (scale > 0) ? val.to_f : val.to_i } if values
  values
end