Class: Spree::PromotionAction

Inherits:
Base
  • Object
show all
Includes:
Spree::Preferences::Persistable, SoftDeletable
Defined in:
app/models/spree/promotion_action.rb

Overview

Base class for all types of promotion action.

PromotionActions perform the necessary tasks when a promotion is activated by an event and determined to be eligible.

Instance Method Summary collapse

Instance Method Details

#available_calculatorsObject



45
46
47
# File 'app/models/spree/promotion_action.rb', line 45

def available_calculators
  Spree::Config.promotions.calculators[self.class]
end

#perform(_options = {}) ⇒ Object

Note:

This method should be overriden in subclassses.

Updates the state of the order or performs some other action depending on the subclass options will contain the payload from the event that activated the promotion. This will include the key :user which allows user based actions to be performed in addition to actions on the order



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

def perform(_options = {})
  raise 'perform should be implemented in a sub-class of PromotionAction'
end

#preload_relationsObject



17
18
19
# File 'app/models/spree/promotion_action.rb', line 17

def preload_relations
  []
end

#remove_from(_order) ⇒ void

Note:

This method should be overriden in subclassses.

This method returns an undefined value.

Removes the action from an order

Parameters:

  • order (Spree::Order)

    the order to remove the action from



37
38
39
# File 'app/models/spree/promotion_action.rb', line 37

def remove_from(_order)
  raise 'remove_from should be implemented in a sub-class of PromotionAction'
end

#to_partial_pathObject



41
42
43
# File 'app/models/spree/promotion_action.rb', line 41

def to_partial_path
  "spree/admin/promotions/actions/#{model_name.element}"
end