Module: ActiveJob::QueueName::ClassMethods

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

Overview

Includes the ability to override the default queue name and prefix.

Instance Method Summary collapse

Instance Method Details

#queue_as(part_name = nil, &block) ⇒ Object

Specifies the name of the queue to process the job on.

class PublishToFeedJob < ActiveJob::Base
  queue_as :feeds

  def perform(post)
    post.to_feed!
  end
end

19
20
21
22
23
24
25
# File 'activejob/lib/active_job/queue_name.rb', line 19

def queue_as(part_name=nil, &block)
  if block_given?
    self.queue_name = block
  else
    self.queue_name = queue_name_from_part(part_name)
  end
end

#queue_name_from_part(part_name) ⇒ Object

:nodoc:


27
28
29
30
31
# File 'activejob/lib/active_job/queue_name.rb', line 27

def queue_name_from_part(part_name) #:nodoc:
  queue_name = part_name || default_queue_name
  name_parts = [queue_name_prefix.presence, queue_name]
  name_parts.compact.join(queue_name_delimiter)
end