Class: Spree::PromotionAction
- Inherits:
-
Object
- Object
- Spree::PromotionAction
- Defined in:
- app/models/spree/promotion_action.rb
Direct Known Subclasses
Spree::Promotion::Actions::CreateAdjustment, Spree::Promotion::Actions::CreateItemAdjustments, Spree::Promotion::Actions::CreateLineItems, Spree::Promotion::Actions::FreeShipping
Instance Method Summary collapse
-
#free_shipping? ⇒ Boolean
Returns true if the promotion action is a free shipping action.
-
#human_description ⇒ String
Returns the human description of the promotion action.
-
#human_name ⇒ String
Returns the human name of the promotion action.
-
#key ⇒ String
Returns the key of the promotion action.
-
#perform(_options = {}) ⇒ Object
This method should be overridden in subclass 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.
Instance Method Details
#free_shipping? ⇒ Boolean
Returns true if the promotion action is a free shipping action
26 27 28 |
# File 'app/models/spree/promotion_action.rb', line 26 def free_shipping? type == 'Spree::Promotion::Actions::FreeShipping' end |
#human_description ⇒ String
Returns the human description of the promotion action
40 41 42 |
# File 'app/models/spree/promotion_action.rb', line 40 def human_description Spree.t("promotion_action_types.#{key}.description") end |
#human_name ⇒ String
Returns the human name of the promotion action
33 34 35 |
# File 'app/models/spree/promotion_action.rb', line 33 def human_name Spree.t("promotion_action_types.#{key}.name") end |
#key ⇒ String
Returns the key of the promotion action
47 48 49 |
# File 'app/models/spree/promotion_action.rb', line 47 def key type.demodulize.underscore end |
#perform(_options = {}) ⇒ Object
This method should be overridden in subclass 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
19 20 21 |
# File 'app/models/spree/promotion_action.rb', line 19 def perform( = {}) raise 'perform should be implemented in a sub-class of PromotionAction' end |