Class: Spree::PromotionAction
- Inherits:
-
Base
- Object
- Base
- Spree::PromotionAction
- 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.
Direct Known Subclasses
Spree::Promotion::Actions::CreateAdjustment, Spree::Promotion::Actions::CreateItemAdjustments, Spree::Promotion::Actions::FreeShipping
Instance Method Summary collapse
- #available_calculators ⇒ Object
-
#perform(_options = {}) ⇒ Object
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.
- #preload_relations ⇒ Object
-
#remove_from(_order) ⇒ void
Removes the action from an order.
- #to_partial_path ⇒ Object
Instance Method Details
#available_calculators ⇒ Object
47 48 49 |
# File 'app/models/spree/promotion_action.rb', line 47 def available_calculators Spree::Config.promotions.calculators[self.class] end |
#perform(_options = {}) ⇒ Object
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
29 30 31 |
# File 'app/models/spree/promotion_action.rb', line 29 def perform( = {}) raise 'perform should be implemented in a sub-class of PromotionAction' end |
#preload_relations ⇒ Object
19 20 21 |
# File 'app/models/spree/promotion_action.rb', line 19 def preload_relations [] end |
#remove_from(_order) ⇒ void
This method should be overriden in subclassses.
This method returns an undefined value.
Removes the action from an order
39 40 41 |
# File 'app/models/spree/promotion_action.rb', line 39 def remove_from(_order) raise 'remove_from should be implemented in a sub-class of PromotionAction' end |
#to_partial_path ⇒ Object
43 44 45 |
# File 'app/models/spree/promotion_action.rb', line 43 def to_partial_path "spree/admin/promotions/actions/#{model_name.element}" end |