Module: Spree::ActiveSalesHelper
- Defined in:
- app/helpers/spree/active_sales_helper.rb
Instance Method Summary collapse
-
#all_active_sale_events ⇒ Object
Get the helper and load from cache when possible.
-
#all_sale_events ⇒ Object
Getter to load all_sale_events Get the helper and load from cache when possible.
-
#all_sale_events=(sale_events) ⇒ Object
Setter to set all_sale_events.
-
#current_active_sale_event ⇒ Object
helper to load current_active_sale_event.
- #current_active_sale_event=(active_sale_event) ⇒ Object
-
#current_permalink?(permalink = nil) ⇒ Boolean
check for current permalink using request split with “?” as there can be parameters.
-
#get_sale_event(object) ⇒ Object
find sale event for the product or a taxon pass taxon or product object in the argument.
Instance Method Details
#all_active_sale_events ⇒ Object
Get the helper and load from cache when possible
17 18 19 |
# File 'app/helpers/spree/active_sales_helper.rb', line 17 def all_active_sale_events all_sale_events.select{ |e| e.type == "Spree::ActiveSaleEvent" && e.parent_id != nil } end |
#all_sale_events ⇒ Object
Getter to load all_sale_events Get the helper and load from cache when possible
5 6 7 |
# File 'app/helpers/spree/active_sales_helper.rb', line 5 def all_sale_events @all_sale_events ||= Spree::SaleEvent.live_active end |
#all_sale_events=(sale_events) ⇒ Object
Setter to set all_sale_events. Set the helper and load from parameter when possible
11 12 13 14 |
# File 'app/helpers/spree/active_sales_helper.rb', line 11 def all_sale_events=(sale_events) return Array.new unless sale_events.class == Array @all_sale_events = sale_events end |
#current_active_sale_event ⇒ Object
helper to load current_active_sale_event
31 32 33 |
# File 'app/helpers/spree/active_sales_helper.rb', line 31 def current_active_sale_event all_sale_events.detect{ |sale_event| current_permalink?(sale_event.permalink) } end |
#current_active_sale_event=(active_sale_event) ⇒ Object
35 36 37 |
# File 'app/helpers/spree/active_sales_helper.rb', line 35 def current_active_sale_event=(active_sale_event) active_sale_event.nil? ? current_active_sale_event : active_sale_event end |
#current_permalink?(permalink = nil) ⇒ Boolean
check for current permalink using request split with “?” as there can be parameters
41 42 43 44 |
# File 'app/helpers/spree/active_sales_helper.rb', line 41 def current_permalink?(permalink = nil) return false if permalink.blank? request.path.split('/').reject(&:blank?).join('/') == permalink end |
#get_sale_event(object) ⇒ Object
find sale event for the product or a taxon pass taxon or product object in the argument
23 24 25 26 27 28 |
# File 'app/helpers/spree/active_sales_helper.rb', line 23 def get_sale_event(object) if ["Spree::Product", "Spree::Taxon"].include? object.class.name active_sale_event = all_sale_events.detect{ |sale_event| (sale_event.eventable_type == object.class.name) && (sale_event.eventable_id == object.id) } end active_sale_event end |