Sha256: 4670f8d47387137faf33b591862128113fb509c34e2c12dbd6260b0b4e7e8073

Contents?: true

Size: 918 Bytes

Versions: 15

Compression:

Stored size: 918 Bytes

Contents

# 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.
module Spree
  class PromotionAction < Spree::Base
    acts_as_paranoid

    belongs_to :promotion, class_name: 'Spree::Promotion'

    scope :of_type, ->(t) { where(type: t) }

    # This method should be overriden 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
    def perform(options = {})
      raise 'perform should be implemented in a sub-class of PromotionAction'
    end

    protected

    def label(amount)
      "#{Spree.t(:promotion)} (#{promotion.name})"
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spree_core-3.0.10 app/models/spree/promotion_action.rb
spree_core-3.0.9 app/models/spree/promotion_action.rb
spree_core-3.0.8 app/models/spree/promotion_action.rb
spree_core-3.0.7 app/models/spree/promotion_action.rb
spree_core-3.0.6.1 app/models/spree/promotion_action.rb
spree_core-3.0.6 app/models/spree/promotion_action.rb
spree_core-3.0.5 app/models/spree/promotion_action.rb
spree_core-3.0.4 app/models/spree/promotion_action.rb
spree_core-3.0.3 app/models/spree/promotion_action.rb
spree_core-3.0.2 app/models/spree/promotion_action.rb
spree_core-3.0.1 app/models/spree/promotion_action.rb
spree_core-3.0.0 app/models/spree/promotion_action.rb
spree_core-3.0.0.rc4 app/models/spree/promotion_action.rb
spree_core-3.0.0.rc3 app/models/spree/promotion_action.rb
spree_core-3.0.0.rc1 app/models/spree/promotion_action.rb