Method: ActiveJob::Callbacks::ClassMethods#before_enqueue

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

#before_enqueue(*filters, &blk) ⇒ Object

Defines a callback that will get called right before the job is enqueued.

class VideoProcessJob < ActiveJob::Base
  queue_as :default

  before_enqueue do |job|
    $statsd.increment "enqueue-video-job.try"
  end

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


123
124
125
# File 'activejob/lib/active_job/callbacks.rb', line 123

def before_enqueue(*filters, &blk)
  set_callback(:enqueue, :before, *filters, &blk)
end