Method: ActiveJob::Callbacks::ClassMethods#around_enqueue

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

#around_enqueue(*filters, &blk) ⇒ Object

Defines a callback that will get called around the enqueuing of the job.

class VideoProcessJob < ActiveJob::Base
  queue_as :default

  around_enqueue do |job, block|
    $statsd.time "video-job.process" do
      block.call
    end
  end

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


163
164
165
# File 'activejob/lib/active_job/callbacks.rb', line 163

def around_enqueue(*filters, &blk)
  set_callback(:enqueue, :around, *filters, &blk)
end