Parent

Cart

Public Instance Methods

add_product(product_id) click to toggle source
    # File app/models/cart.rb, line 4
 4:   def add_product(product_id)

 5:     current_item = line_items.find_by_product_id(product_id)

 6:     if current_item

 7:       current_item.quantity += 1

 8:     else

 9:      current_item = line_items.build(:product_id => product_id)

10:     end

11:     current_item

12:   end
total_items() click to toggle source
    # File app/models/cart.rb, line 18
18:   def total_items

19:     line_items.sum(:quantity)

20:   end
total_price() click to toggle source
    # File app/models/cart.rb, line 14
14:   def total_price

15:     line_items.to_a.sum { |item| item.total_price }

16:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.