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
24 25 26 |
# File 'app/models/spree/promotion_action.rb', line 24 def free_shipping? type == 'Spree::Promotion::Actions::FreeShipping' end |
#human_description ⇒ String
Returns the human description of the promotion action
38 39 40 |
# File 'app/models/spree/promotion_action.rb', line 38 def human_description Spree.t("promotion_action_types.#{key}.description") end |
#human_name ⇒ String
Returns the human name of the promotion action
31 32 33 |
# File 'app/models/spree/promotion_action.rb', line 31 def human_name Spree.t("promotion_action_types.#{key}.name") end |
#key ⇒ String
Returns the key of the promotion action
45 46 47 |
# File 'app/models/spree/promotion_action.rb', line 45 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
17 18 19 |
# File 'app/models/spree/promotion_action.rb', line 17 def perform( = {}) raise 'perform should be implemented in a sub-class of PromotionAction' end |