Class: PromotionRule

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

Overview

Base class for all promotion rules

Constant Summary collapse

@@rule_classes =
Set.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registerObject



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

def self.register
  @@rule_classes.add(self)
end

.rule_class_namesObject



22
23
24
# File 'app/models/promotion_rule.rb', line 22

def self.rule_class_names
  PromotionRule.rule_classes.map(&:name)
end

.rule_classesObject



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

def self.rule_classes
  @@rule_classes.to_a
end

Instance Method Details

#eligible?(order) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'app/models/promotion_rule.rb', line 8

def eligible?(order)
  raise 'eligible? should be implemented in a sub-class of Promotion::PromotionRule'
end