From 9832e17c3ce7a7405eaa1c69da23773b055588c7 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 12 Mar 2015 10:28:16 -0700 Subject: `QueueAdapters` does the lookup --- activejob/lib/active_job/queue_adapter.rb | 6 +----- activejob/lib/active_job/queue_adapters.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'activejob/lib/active_job') diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index e1f104dc60..9c4519432d 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -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 diff --git a/activejob/lib/active_job/queue_adapters.rb b/activejob/lib/active_job/queue_adapters.rb index 4b91c93dbe..29f28963b4 100644 --- a/activejob/lib/active_job/queue_adapters.rb +++ b/activejob/lib/active_job/queue_adapters.rb @@ -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 -- cgit v1.2.3