Sha256: 02cfd6651f02352b92e4dc23033931912958a10f1b3ef506a1f3ca09c0106062

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

Counterfeit
===========

This gem helps you count somebody's money in your Rails application.
It is basically a nice rails-wrapper for Money gem.

Installation
------------
Gemfile:

    gem 'counterfeit'

Console:

    bundle install

Usage
-----

In your migrations:

    create_table(:products) do |t|
      t.integer :price_in_cents, :default => 0, :null => false
      t.string  :price_currency, :limit => 3,   :null => false
    end

or

    create_table(:products) do |t|
      t.money :price
    end

In your models:

    class Product < ActiveRecord::Base
      has_counterfeit :price
    end

You can specify default currency like this:

    has_counterfeit :price, :currency => 'EUR'

Now lets play a little:

    product = Product.new
    product.price
    # => #<Money cents:0 currency:USD>
    product.price = 500
    product.price
    # => #<Money cents:50000 currency:USD>
    product.price.exchange_to('EUR')
    # => #<Money cents:35491 currency:EUR>
    user = User.new
    user.balance = Money.new(100000, 'RUB')
    user.balance > product.price
    # => false
    # need moar moneez

You can get more info on the ```money``` gem page here: https://github.com/RubyMoney/money


License
-------
Counterfeit is released under the MIT license.

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
counterfeit-0.0.3 README.md
counterfeit-0.0.2 README.md
counterfeit-0.0.1 README.md