End chapter 8
[depot.git] / app / models / cart_item.rb
1 class CartItem
2 attr_reader :product, :quantity
3
4 def initialize(product)
5 @product = product
6 @quantity = 1
7 end
8
9 def increment_quantity
10 @quantity += 1
11 end
12
13 def title
14 @product.title
15 end
16
17 def price
18 @product.price * @quantity
19 end
20
21 end