Class: Spree::PromotionRule

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

Class Method Summary collapse

Instance Method Summary collapse

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

#applicable?(promotable) ⇒ Boolean

Returns:

  • (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

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

Returns:

  • (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