Class: Effective::EventProduct
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::EventProduct
- Defined in:
- app/models/effective/event_product.rb
Instance Method Summary collapse
-
#available? ⇒ Boolean
Available for purchase.
- #capacity_available ⇒ Object
- #capacity_available? ⇒ Boolean
- #purchased_event_addons_count ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#available? ⇒ Boolean
Available for purchase
48 49 50 51 |
# File 'app/models/effective/event_product.rb', line 48 def available? return false if archived? capacity_available? end |
#capacity_available ⇒ Object
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
53 54 55 |
# File 'app/models/effective/event_product.rb', line 53 def capacity_available? capacity.blank? || (capacity_available > 0) end |
#purchased_event_addons_count ⇒ Object
62 63 64 |
# File 'app/models/effective/event_product.rb', line 62 def purchased_event_addons_count purchased_event_addons.length end |
#to_s ⇒ Object
43 44 45 |
# File 'app/models/effective/event_product.rb', line 43 def to_s title.presence || 'New Event Product' end |