Module: Ticket::Pricing

Extended by:
ActiveSupport::Concern
Included in:
Ticket
Defined in:
app/models/ticket/pricing.rb

Instance Method Summary collapse

Instance Method Details

#cart_priceObject



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_cartObject



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_priceObject



29
30
31
# File 'app/models/ticket/pricing.rb', line 29

def set_cart_price
  self.cart_price ||= self.price
end