Sha256: d94d2f8f2a9680f5e16a75b51ab2dd8af7d1197b835de0243b9d15889629a3d3
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
= dm-money == Description BigMoney backed DataMapper money properties. == Todo * Validations. * Precision and scale options should also be applied to underlying BigMoney/BigDecimal amount. * A rounding mode option, see BigDecimal#mode. == Synopsis === Basic require 'dm-core' require 'dm-money' class Cake include DataMapper::Resource # ... other properties. money :gst # public # gst #=> BigMoney # gst=(value) # # property :gst_amount, BigDecimal, accessor: private # property :gst_currency, String, accessor: private, length: 3 end === Property Options require 'dm-core' require 'dm-money' class Cake include DataMapper::Resource # ... other properties. money :price, required: true, accessor: protected # protected # price #=> BigMoney # price=(value) # # property :price_amount, BigDecimal, accessor: private, required: true # property :price_currency, String, accessor: private, required: true, length: 3 end == Precision and Scale "The SQL standard requires a default scale of 0, i.e. coercion to integer precision. We find this a bit useless. If you're concerned about portability, always specify the precision and scale explicitly." -- PostgreSQL Documentation. DataMapper's bread and butter is SQL and old school relational databases so unsurprisingly a default numeric/decimal scale of 0 is used (where the default precision comes from I do not know). If you require any fractional money amounts remember to explicitly set the precision and scale options for each money property. == Install * Via git: git clone git://github.com/shanna/dm-money.git cd dm-money && rake install * Via gem: gem install dm-money == License See LICENSE.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-money-0.2.0 | README.rdoc |
dm-money-0.1.4 | README.rdoc |