Class: Spree::SaleEvent
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::SaleEvent
show all
- Defined in:
- app/models/spree/sale_event.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.not_blank_and_sorted_by(column) ⇒ Object
59
60
61
62
63
|
# File 'app/models/spree/sale_event.rb', line 59
def not_blank_and_sorted_by(column)
return nil if column.blank?
column = column.to_sym
self.select(&column).map(&column).reject(&:blank?).sort
end
|
.paginate(objects_per_page, options = {}) ⇒ Object
54
55
56
57
|
# File 'app/models/spree/sale_event.rb', line 54
def paginate(objects_per_page, options = {})
options = (objects_per_page, options)
self.page(options[:page]).per(options[:per_page])
end
|
Instance Method Details
#invalid_dates? ⇒ Boolean
48
49
50
|
# File 'app/models/spree/sale_event.rb', line 48
def invalid_dates?
self.start_and_end_dates_available? and (self.start_date >= self.end_date)
end
|
#live?(moment = nil) ⇒ Boolean
25
26
27
28
|
# File 'app/models/spree/sale_event.rb', line 25
def live?(moment=nil)
moment ||= object_zone_time
(self.start_date <= moment and self.end_date >= moment) or self.is_permanent? if start_and_end_dates_available?
end
|
#live_and_active?(moment = nil) ⇒ Boolean
40
41
42
|
# File 'app/models/spree/sale_event.rb', line 40
def live_and_active?(moment=nil)
self.live?(moment) and self.is_active?
end
|
#past? ⇒ Boolean
35
36
37
38
|
# File 'app/models/spree/sale_event.rb', line 35
def past?
current_time = object_zone_time
(self.start_date < current_time and self.end_date > self.start_date and self.end_date < current_time) if start_and_end_dates_available?
end
|
#start_and_end_dates_available? ⇒ Boolean
44
45
46
|
# File 'app/models/spree/sale_event.rb', line 44
def start_and_end_dates_available?
self.start_date and self.end_date
end
|
#upcoming? ⇒ Boolean
30
31
32
33
|
# File 'app/models/spree/sale_event.rb', line 30
def upcoming?
current_time = object_zone_time
(self.start_date >= current_time and self.end_date > self.start_date) if start_and_end_dates_available?
end
|