beezwax / acts-as-price-tag

This plugin adds a price methods (with currency support) to any active record object. It acts as a wrapper around Tobias Luetke's money gem.

This URL has Read+Write access

acts-as-price-tag / README
100644 22 lines (18 sloc) 0.709 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
== Usage
 
This plugin adds price accessor and assignment methods to any active record object.
It expects cents:integer and currency:string fields in the database.
The money functionality is drawn from ruby's money gem.
the price= method will accept a Money object or any object with a to_money method implemented.
 
# class Product < ActiveRecord::Base
# has_many :product_units
# acts_as_price_tag
# end
#
# product = Product.new
# product.price = "EUR1000"
# => "EUR1000"
# product.price
# => #<Money:0x235607c @currency="EUR", @cents=100000>
# product.price = Money.new(55500, "USD")
# => #<Money:0x232ca9c @currency="USD", @cents=55500>
 
Money gem readme/license included in lib.