Class: Spree::PriceRule
- Inherits:
-
Object
- Object
- Spree::PriceRule
- Defined in:
- app/models/spree/price_rule.rb
Direct Known Subclasses
Spree::PriceRules::CustomerGroupRule, Spree::PriceRules::MarketRule, Spree::PriceRules::UserRule, Spree::PriceRules::VolumeRule, Spree::PriceRules::ZoneRule
Class Method Summary collapse
-
.description ⇒ String
Returns the description of the price rule.
-
.human_name ⇒ String
Returns the human name of the price rule.
-
.registered_subclasses ⇒ Object
Pull the rule registry off the global pricing config so PreferenceSchema’s ‘.subclasses_with_preference_schema` can power the admin’s “Add rule” picker.
Instance Method Summary collapse
-
#applicable?(context) ⇒ Boolean
Returns true if the price rule is applicable to the context.
Class Method Details
.description ⇒ String
Returns the description of the price rule
27 28 29 |
# File 'app/models/spree/price_rule.rb', line 27 def self.description '' end |
.human_name ⇒ String
Returns the human name of the price rule
21 22 23 |
# File 'app/models/spree/price_rule.rb', line 21 def self.human_name name.demodulize.titleize end |
.registered_subclasses ⇒ Object
Pull the rule registry off the global pricing config so PreferenceSchema’s ‘.subclasses_with_preference_schema` can power the admin’s “Add rule” picker.
34 35 36 |
# File 'app/models/spree/price_rule.rb', line 34 def self.registered_subclasses Array(Spree.pricing&.rules) end |
Instance Method Details
#applicable?(context) ⇒ Boolean
Returns true if the price rule is applicable to the context
15 16 17 |
# File 'app/models/spree/price_rule.rb', line 15 def applicable?(context) raise NotImplementedError, "#{self.class.name} must implement #applicable?" end |