Class: SolidusFriendlyPromotions::PromotionCodeBatchJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/solidus_friendly_promotions/promotion_code_batch_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(promotion_code_batch) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/jobs/solidus_friendly_promotions/promotion_code_batch_job.rb', line 7

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

  if promotion_code_batch.email?
    SolidusFriendlyPromotions.config.promotion_code_batch_mailer_class
      .promotion_code_batch_finished(promotion_code_batch)
      .deliver_now
  end
rescue => e
  if promotion_code_batch.email?
    SolidusFriendlyPromotions.config.promotion_code_batch_mailer_class
      .promotion_code_batch_errored(promotion_code_batch)
      .deliver_now
  end
  raise e
end