Dollarr
Easily wrap _in_cents integer columns with getters and setters that work with dollars.
Installation
Add this line to your application's Gemfile:
gem 'dollarr'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dollarr
Usage
class Product
include Mongoid::Document
field :name
field :cost_in_cents, type: Integer, default: 0
incldue Dollarr
end
p = Product.new(cost: 15)
p.cost # => 15
p.cost_in_cents # => 1500
Works with ActiveRecord too.
Contributing
- Fork it ( https://github.com/[my-github-username]/dollarr/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request