Class: Spree::PromotionRule

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/promotion_rule.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

page

Methods included from Spree::Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Class Method Details

.for(promotable) ⇒ Object


11
12
13
# File 'app/models/spree/promotion_rule.rb', line 11

def self.for(promotable)
  all.select { |rule| rule.applicable?(promotable) }
end

Instance Method Details

#actionable?(line_item) ⇒ Boolean

This states if a promotion can be applied to the specified line item It is true by default, but can be overridden by promotion rules to provide conditions


25
26
27
# File 'app/models/spree/promotion_rule.rb', line 25

def actionable?(line_item)
  true
end

#applicable?(promotable) ⇒ Boolean


15
16
17
# File 'app/models/spree/promotion_rule.rb', line 15

def applicable?(promotable)
  raise 'applicable? should be implemented in a sub-class of Spree::PromotionRule'
end

#eligibility_errorsObject


29
30
31
# File 'app/models/spree/promotion_rule.rb', line 29

def eligibility_errors
  @eligibility_errors ||= ActiveModel::Errors.new(self)
end

#eligible?(promotable, options = {}) ⇒ Boolean


19
20
21
# File 'app/models/spree/promotion_rule.rb', line 19

def eligible?(promotable, options = {})
  raise 'eligible? should be implemented in a sub-class of Spree::PromotionRule'
end