Method: ActiveJob::Callbacks::ClassMethods#around_perform

Defined in:
activejob/lib/active_job/callbacks.rb

#around_perform(*filters, &blk) ⇒ Object

Defines a callback that will get called around the job’s perform method.

class VideoProcessJob < ActiveJob::Base
  queue_as :default

  around_perform do |job, block|
    UserMailer.notify_video_started_processing(job.arguments.first)
    block.call
    UserMailer.notify_video_processed(job.arguments.first)
  end

  def perform(video_id)
    Video.find(video_id).process
  end
end


104
105
106
# File 'activejob/lib/active_job/callbacks.rb', line 104

def around_perform(*filters, &blk)
  set_callback(:perform, :around, *filters, &blk)
end