Class: ActiveJob::Queues

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/active_job/queues.rb

Overview

An enumerable collection of queues that supports direct access to queues by name.

queue_1 = ApplicationJob::Queue.new("queue_1")
queue_2 = ApplicationJob::Queue.new("queue_2")
queues = ApplicationJob::Queues.new([queue_1, queue_2])

queues[:queue_1] #=> queue_1
queues[:queue_2] #=> queue_2
queues.to_a #=> [ queue_1, queue_2 ] # Enumerable

See ActiveJob::Queue.

Instance Method Summary collapse

Constructor Details

#initialize(queues) ⇒ Queues

Returns a new instance of Queues.



19
20
21
# File 'lib/active_job/queues.rb', line 19

def initialize(queues)
  @queues_by_id = queues.index_by(&:id).with_indifferent_access
end

Instance Method Details

#[](name) ⇒ Object



27
28
29
# File 'lib/active_job/queues.rb', line 27

def [](name)
  queues_by_id[name.to_s.parameterize]
end

#to_hObject



23
24
25
# File 'lib/active_job/queues.rb', line 23

def to_h
  queues_by_id.dup
end