Class: Effective::EventProduct

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/event_product.rb

Instance Method Summary collapse

Instance Method Details

#available?Boolean

Available for purchase

Returns:

  • (Boolean)


48
49
50
51
# File 'app/models/effective/event_product.rb', line 48

def available?
  return false if archived?
  capacity_available?
end

#capacity_availableObject



57
58
59
60
# File 'app/models/effective/event_product.rb', line 57

def capacity_available
  return nil if capacity.blank?
  [(capacity - purchased_event_addons_count), 0].max
end

#capacity_available?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/models/effective/event_product.rb', line 53

def capacity_available?
  capacity.blank? || (capacity_available > 0)
end

#purchased_event_addons_countObject



62
63
64
# File 'app/models/effective/event_product.rb', line 62

def purchased_event_addons_count
  purchased_event_addons.length
end

#to_sObject



43
44
45
# File 'app/models/effective/event_product.rb', line 43

def to_s
  title.presence || 'New Event Product'
end