Module: Ticket::Pricing
Instance Method Summary collapse
- #cart_price ⇒ Object
- #change_price(new_price) ⇒ Object
- #exchange_prices_from(old_ticket) ⇒ Object
- #remove_from_cart ⇒ Object
-
#reset_price! ⇒ Object
This is guarded with sold? Because of the DelayedJob that expires tickets.
- #set_cart_price ⇒ Object
Instance Method Details
#cart_price ⇒ Object
33 34 35 |
# File 'app/models/ticket/pricing.rb', line 33 def cart_price self[:cart_price] || self.price end |
#change_price(new_price) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/models/ticket/pricing.rb', line 37 def change_price(new_price) unless self.committed? or new_price.to_i < 0 self.price = new_price self.save! else return false end end |
#exchange_prices_from(old_ticket) ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/models/ticket/pricing.rb', line 21 def exchange_prices_from(old_ticket) self.sold_price = old_ticket.sold_price self.cart_price = old_ticket.sold_price self.discount_id= old_ticket.discount_id self.cart_id = nil self.save end |
#remove_from_cart ⇒ Object
4 5 6 |
# File 'app/models/ticket/pricing.rb', line 4 def remove_from_cart self.update_column(:cart_id, nil) end |
#reset_price! ⇒ Object
This is guarded with sold? Because of the DelayedJob that expires tickets. The job Removes them from cart regardless of state. If they’ve been sold, we want that information retained
12 13 14 15 16 17 18 19 |
# File 'app/models/ticket/pricing.rb', line 12 def reset_price! return false if sold? self.cart_price = self.price self.discount = nil self.sold_price = nil self.save end |
#set_cart_price ⇒ Object
29 30 31 |
# File 'app/models/ticket/pricing.rb', line 29 def set_cart_price self.cart_price ||= self.price end |