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)
|
def interpret_adapter(name_or_adapter_or_class)
|
||||||
case name_or_adapter_or_class
|
case name_or_adapter_or_class
|
||||||
when Symbol, String
|
when Symbol, String
|
||||||
load_adapter(name_or_adapter_or_class)
|
ActiveJob::QueueAdapters.lookup(name_or_adapter_or_class).new
|
||||||
else
|
else
|
||||||
if queue_adapter?(name_or_adapter_or_class)
|
if queue_adapter?(name_or_adapter_or_class)
|
||||||
name_or_adapter_or_class
|
name_or_adapter_or_class
|
||||||
|
@ -56,10 +56,6 @@ module ActiveJob
|
||||||
def queue_adapter_class?(object)
|
def queue_adapter_class?(object)
|
||||||
object.is_a?(Class) && QUEUE_ADAPTER_METHODS.all? { |meth| object.public_method_defined?(meth) }
|
object.is_a?(Class) && QUEUE_ADAPTER_METHODS.all? { |meth| object.public_method_defined?(meth) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_adapter(name)
|
|
||||||
ActiveJob::QueueAdapters.const_get(name.to_s.camelize + 'Adapter').new
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,5 +48,13 @@ module ActiveJob
|
||||||
autoload :SneakersAdapter
|
autoload :SneakersAdapter
|
||||||
autoload :SuckerPunchAdapter
|
autoload :SuckerPunchAdapter
|
||||||
autoload :TestAdapter
|
autoload :TestAdapter
|
||||||
|
|
||||||
|
ADAPTER = 'Adapter'.freeze
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def lookup(name)
|
||||||
|
const_get(name.to_s.camelize << ADAPTER)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue