BigDecimalConverter

Constants

Methods

.convert_type

def convert_type
  BigDecimal
end

.converted?

def converted?(value)
  value.is_a?(db_type)
end

.db_type

def db_type
  BigDecimal
end

.to_db

def to_db(value)
  case value
  when Rational
    value.to_f.to_d
  when respond_to?(:to_d)
    value.to_d
  else
    BigDecimal.new(value.to_s)
  end
end

.to_ruby

def to_db(value)
  case value
  when Rational
    value.to_f.to_d
  when respond_to?(:to_d)
    value.to_d
  else
    BigDecimal.new(value.to_s)
  end
end