Skip to content

Instantly share code, notes, and snippets.

@savonarola
Created May 29, 2011 14:45
Show Gist options
  • Save savonarola/997823 to your computer and use it in GitHub Desktop.
Save savonarola/997823 to your computer and use it in GitHub Desktop.
module Cart
def add(buyer, catalog, product_id, quantity)
raise ArgumentError unless user.kind_of?(Buyer)
raise ArgumentError unless catalog.kind_of?(Catalog)
# или через #respond_to?
product = catalog.find_product(product_id)
add_cart_items(quantity, CartItem.new(buyer,product))
end
end
class User
include Buyer
end
class Shop
include Catalog
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment