Sha256: b3ab4cc4dbcb1952b68170223aad84f044280c1135bcb28bcfb3ad725cbc75d0

Contents?: true

Size: 725 Bytes

Versions: 14

Compression:

Stored size: 725 Bytes

Contents

#
# This class manages all the things we need to do after a sale is made
#
# TODO: Add sending email.
#
class OrderProcessor < Struct.new(:order, :skip_actions)
  include ActionView::Helpers::TextHelper
  QUEUE = "order"

  def self.process(order, skip_actions = false)
    job = OrderProcessor.new(order, skip_actions)
    Delayed::Job.enqueue job, :queue => QUEUE
  end

  def perform
    self.order.create_donation_actions unless self.skip_actions
    self.order.create_purchase_action  unless self.skip_actions

    process_memberships
  end

  def process_memberships
    self.order.memberships.each do |membership_item|
      Member.for(membership_item.product)
    end
    self.order.create_membership_action
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.15 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.12 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.11 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.10 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.9 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.8 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.7 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.6 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.5 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.4 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.3 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.2 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre.1 app/models/job/order_processor.rb
artfully_ose-1.2.0.pre app/models/job/order_processor.rb