Module: ActiveJob::QueueAdapter::ClassMethods

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

Overview

Includes the setter method for changing the active queue adapter.

Instance Method Summary collapse

Instance Method Details

#queue_adapterObject

Returns the backend queue provider. The default queue adapter is the :async queue. See QueueAdapters for more information.



26
27
28
# File 'activejob/lib/active_job/queue_adapter.rb', line 26

def queue_adapter
  _queue_adapter
end

#queue_adapter=(name_or_adapter) ⇒ Object

Specify the backend queue provider. The default queue adapter is the :async queue. See QueueAdapters for more information.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'activejob/lib/active_job/queue_adapter.rb', line 39

def queue_adapter=(name_or_adapter)
  case name_or_adapter
  when Symbol, String
    queue_adapter = ActiveJob::QueueAdapters.lookup(name_or_adapter).new
    assign_adapter(name_or_adapter.to_s, queue_adapter)
  else
    if queue_adapter?(name_or_adapter)
      adapter_name = "#{name_or_adapter.class.name.demodulize.remove('Adapter').underscore}"
      assign_adapter(adapter_name, name_or_adapter)
    else
      raise ArgumentError
    end
  end
end

#queue_adapter_nameObject

Returns string denoting the name of the configured queue adapter. By default returns "async".



32
33
34
# File 'activejob/lib/active_job/queue_adapter.rb', line 32

def queue_adapter_name
  _queue_adapter_name
end