mirror of https://github.com/rails/rails
`QueueAdapters` does the lookup
This commit is contained in:
parent
ccf8678cec
commit
9832e17c3c
|
@ -31,7 +31,7 @@ module ActiveJob
|
|||
def interpret_adapter(name_or_adapter_or_class)
|
||||
case name_or_adapter_or_class
|
||||
when Symbol, String
|
||||
load_adapter(name_or_adapter_or_class)
|
||||
ActiveJob::QueueAdapters.lookup(name_or_adapter_or_class).new
|
||||
else
|
||||
if queue_adapter?(name_or_adapter_or_class)
|
||||
name_or_adapter_or_class
|
||||
|
@ -56,10 +56,6 @@ module ActiveJob
|
|||
def queue_adapter_class?(object)
|
||||
object.is_a?(Class) && QUEUE_ADAPTER_METHODS.all? { |meth| object.public_method_defined?(meth) }
|
||||
end
|
||||
|
||||
def load_adapter(name)
|
||||
ActiveJob::QueueAdapters.const_get(name.to_s.camelize + 'Adapter').new
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,5 +48,13 @@ module ActiveJob
|
|||
autoload :SneakersAdapter
|
||||
autoload :SuckerPunchAdapter
|
||||
autoload :TestAdapter
|
||||
|
||||
ADAPTER = 'Adapter'.freeze
|
||||
|
||||
class << self
|
||||
def lookup(name)
|
||||
const_get(name.to_s.camelize << ADAPTER)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue