Sha256: 47a12008d46872c8ff2fc6b6991c79f74025214dfc9b4ecfccf420de76079294

Contents?: true

Size: 828 Bytes

Versions: 12

Compression:

Stored size: 828 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 < ActiveRecord::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
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spree_core-2.2.14 app/models/spree/promotion_action.rb
spree_core-2.2.13 app/models/spree/promotion_action.rb
spree_core-2.2.12 app/models/spree/promotion_action.rb
spree_core-2.2.11 app/models/spree/promotion_action.rb
spree_core-2.2.10 app/models/spree/promotion_action.rb
spree_core-2.2.9 app/models/spree/promotion_action.rb
spree_core-2.2.8 app/models/spree/promotion_action.rb
spree_core-2.2.7 app/models/spree/promotion_action.rb
spree_core-2.2.6 app/models/spree/promotion_action.rb
spree_core-2.2.5 app/models/spree/promotion_action.rb
spree_core-2.2.4 app/models/spree/promotion_action.rb
spree_core-2.2.3 app/models/spree/promotion_action.rb