Skip to content

Commit

Permalink
CartItem クラス追加
Browse files Browse the repository at this point in the history
  • Loading branch information
kyanny committed Jan 20, 2010
1 parent 6d98495 commit 75b7270
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 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

0 comments on commit 75b7270

Please sign in to comment.