Class: LineItem

Inherits:
ActiveRecord::Base show all
Defined in:
app/models/line_item.rb

Instance Method Summary collapse

Instance Method Details

#priceObject



24
25
26
# File 'app/models/line_item.rb', line 24

def price
  product_price * quantity
end

#update_quantity(count) ⇒ Object

updates quantity count. If count is zero then deletes the line_item .



29
30
31
32
# File 'app/models/line_item.rb', line 29

def update_quantity(count)
  count = count.to_i
  (count > 0) ? update_attributes(quantity: count) : destroy
end