X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=app%2Fmodels%2Fcart_item.rb;fp=app%2Fmodels%2Fcart_item.rb;h=6924ed7fdaf275dcc2eccfd4cf16a240de01e213;hb=c611b802645df9f0b490550d8c352fd24eb6ec5b;hp=0000000000000000000000000000000000000000;hpb=e0bbc73cee316aa3fdaae981e567de2443799be3;p=depot.git

diff --git a/app/models/cart_item.rb b/app/models/cart_item.rb
new file mode 100644
index 0000000..6924ed7
--- /dev/null
+++ b/app/models/cart_item.rb
@@ -0,0 +1,21 @@
+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