Module: Carter::ActiveRecord::Cartable
- Defined in:
- lib/carter/cartable.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#acts_as_cartable(options = {}) ⇒ Object
Options acts_as_cartable :name => “name_column”, :price => “price_column”, :unique => true / false :unique => true # this allows only one item of this type in the cart.
- #cartable_configuration ⇒ Object
Instance Method Details
#acts_as_cartable(options = {}) ⇒ Object
Options
acts_as_cartable :name => "name_column", :price => "price_column", :unique => true / false
:unique => true # this allows only one item of this type in the cart.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/carter/cartable.rb', line 8 def acts_as_cartable( = {}) configuration = { :name => "name", :price => "price", :unique => false } configuration.update() if .is_a?(Hash) @cartable_configuration = configuration has_many :cart_items, :as => :cartable has_many :carts, :through => :cart_items register_cartable(self) include InstanceMethods true end |
#cartable_configuration ⇒ Object
19 20 21 |
# File 'lib/carter/cartable.rb', line 19 def cartable_configuration @cartable_configuration ||= {} end |