W3cubDocs

/Ruby on Rails 7.0

module ActiveJob::QueuePriority::ClassMethods

Includes the ability to override the default queue priority.

Public Instance Methods

queue_with_priority(priority = nil, &block) Show source
# File activejob/lib/active_job/queue_priority.rb, line 22
def queue_with_priority(priority = nil, &block)
  if block_given?
    self.priority = block
  else
    self.priority = priority
  end
end

Specifies the priority of the queue to create the job with.

class PublishToFeedJob < ActiveJob::Base
  queue_with_priority 50

  def perform(post)
    post.to_feed!
  end
end

Specify either an argument or a block.

© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.