Class: Spree::ActiveSale::Event
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::ActiveSale::Event
- Defined in:
- app/models/spree/active_sale/event.rb
Class Method Summary collapse
-
.is_live?(object) ⇒ Boolean
Spree::ActiveSale::Event.is_live? method should only/ always represents live and active events and not just live events.
Instance Method Summary collapse
Class Method Details
.is_live?(object) ⇒ Boolean
Spree::ActiveSale::Event.is_live? method should only/ always represents live and active events and not just live events.
46 47 48 49 50 |
# File 'app/models/spree/active_sale/event.rb', line 46 def self.is_live? object object_class_name = object.class.name return (object.live_and_active?) if object_class_name == self.name %w(Spree::Product Spree::Variant Spree::Taxon).include?(object_class_name) ? object.live? : false end |
Instance Method Details
#live? ⇒ Boolean
35 36 37 38 |
# File 'app/models/spree/active_sale/event.rb', line 35 def live? current_time = Time.now (self.start_date <= current_time and self.end_date >= current_time) or self.is_permanent? end |
#live_and_active? ⇒ Boolean
40 41 42 |
# File 'app/models/spree/active_sale/event.rb', line 40 def live_and_active? self.live? and self.is_active? end |
#validate_start_and_end_date ⇒ Object
31 32 33 |
# File 'app/models/spree/active_sale/event.rb', line 31 def validate_start_and_end_date errors.add(:start_date, I18n.t('spree.active_sale.event.validation.errors.invalid_dates')) if (self.start_date and self.end_date) and (self.start_date > self.end_date) end |