Sha256: 4f30ebba28861fac65ffc989327d867c7c80df97044eef1f78dd78d5ae144d84
Contents?: true
Size: 887 Bytes
Versions: 3
Compression:
Stored size: 887 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::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
3 entries across 3 versions & 1 rubygems