Sha256: c02c2bccd98525a62c43da866dc7995fef981f52288f422107900f0e86cd23f5
Contents?: true
Size: 979 Bytes
Versions: 1
Compression:
Stored size: 979 Bytes
Contents
module ActiveRecord module Acts module ShoppingCart def self.included(base) base.extend(ClassMethods) end module ClassMethods # # Prepares the class to act as a cart. # # Receives as a parameter the name of the class that will hold the items # # Example: # # acts_as_shopping_cart :cart_item # # def acts_as_shopping_cart_using(item_class) self.send :include, ActiveRecord::Acts::ShoppingCart::Cart::InstanceMethods self.send :include, ActiveRecord::Acts::ShoppingCart::Item::InstanceMethods has_many :cart_items, :class_name => item_class.to_s.classify, :as => :owner end # # Alias for: # # acts_as_shopping_cart_using :shopping_cart_item # def acts_as_shopping_cart acts_as_shopping_cart_using :shopping_cart_item end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_shopping_cart-0.1.0 | lib/active_record/acts/shopping_cart.rb |