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

  1. Fork it ( https://github.com/[my-github-username]/dollarr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request