diff --git a/depot/app/models/cart_item.rb b/depot/app/models/cart_item.rb new file mode 100644 index 0000000..8fe0f04 --- /dev/null +++ b/depot/app/models/cart_item.rb @@ -0,0 +1,20 @@ +class CartItem + attr_reader :product, :quantity + + def initialize (product) + @product = product + @quantity = 1 + end + + def increment_quantity + @quantity += 1 + end + + def title + @product.title + end + + def price + @product.price * @quantity + end +end