Class: Spree::PriceRule

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionString

Returns the description of the price rule

Returns:

  • (String)


27
28
29
# File 'app/models/spree/price_rule.rb', line 27

def self.description
  ''
end

.human_nameString

Returns the human name of the price rule

Returns:

  • (String)


21
22
23
# File 'app/models/spree/price_rule.rb', line 21

def self.human_name
  name.demodulize.titleize
end

.registered_subclassesObject

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

Parameters:

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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

def applicable?(context)
  raise NotImplementedError, "#{self.class.name} must implement #applicable?"
end