Sha256: 8e24c7ace6a6349d62a6da72c54312afd8bf4da85cff9c84c5541288c58cae9a

Contents?: true

Size: 721 Bytes

Versions: 5

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

module Spree
  class PromotionCodeBatchJob < ActiveJob::Base
    queue_as :default

    def perform(promotion_code_batch)
      PromotionCode::BatchBuilder.new(
        promotion_code_batch
      ).build_promotion_codes

      if promotion_code_batch.email?
        Spree::Config.promotions.promotion_code_batch_mailer_class
          .promotion_code_batch_finished(promotion_code_batch)
          .deliver_now
      end
    rescue StandardError => error
      if promotion_code_batch.email?
        Spree::Config.promotions.promotion_code_batch_mailer_class
          .promotion_code_batch_errored(promotion_code_batch)
          .deliver_now
      end
      raise error
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_legacy_promotions-4.5.1 app/jobs/spree/promotion_code_batch_job.rb
solidus_legacy_promotions-4.5.0 app/jobs/spree/promotion_code_batch_job.rb
solidus_legacy_promotions-4.4.2 app/jobs/spree/promotion_code_batch_job.rb
solidus_legacy_promotions-4.4.1 app/jobs/spree/promotion_code_batch_job.rb
solidus_legacy_promotions-4.4.0 app/jobs/spree/promotion_code_batch_job.rb