Created
May 29, 2011 14:45
-
-
Save savonarola/997823 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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