Sha256: a67f896eda48bf0fd2f678d1b159e0de6f412f139bb48037de59bf59eb3519e2

Contents?: true

Size: 292 Bytes

Versions: 2

Compression:

Stored size: 292 Bytes

Contents

class MoneyType < ActiveRecord::Type::Integer
  def cast(value)
    if !value.is_a?(Numeric) && value.include?('$')
      price_in_dollars = value.delete('$').to_f
      super(price_in_dollars * 100)
    else
      super
    end
  end
end

ActiveRecord::Type.register(:money_type, MoneyType)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
store_attribute-0.5.2 spec/support/money_type.rb
store_attribute-0.5.1 spec/support/money_type.rb