Sha256: 6731b7c29343ea9d98ff4d554f7687b2bf9bb244e6cba8ba53724b33672c96be

Contents?: true

Size: 906 Bytes

Versions: 2

Compression:

Stored size: 906 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
    belongs_to :promotion, :foreign_key => 'activator_id'

    scope :of_type, lambda {|t| {:conditions => {:type => t}}}

    attr_accessible :line_items_string, :calculator_type, :calculator_attributes

    # 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

2 entries across 2 versions & 1 rubygems

Version Path
spree_promo-1.0.7 app/models/spree/promotion_action.rb
spree_promo-1.0.6 app/models/spree/promotion_action.rb