aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@gmail.com>2015-03-12 10:28:16 -0700
committerTamir Duberstein <tamird@gmail.com>2015-03-12 21:55:19 -0700
commit9832e17c3ce7a7405eaa1c69da23773b055588c7 (patch)
tree0d31900958b5228c3f80cd2ceb6e3765327b26bb /activejob
parentccf8678cec9228a08d01b5a7dc9552821bdc2686 (diff)
downloadrails-9832e17c3ce7a7405eaa1c69da23773b055588c7.tar.gz
rails-9832e17c3ce7a7405eaa1c69da23773b055588c7.tar.bz2
rails-9832e17c3ce7a7405eaa1c69da23773b055588c7.zip
`QueueAdapters` does the lookup
Diffstat (limited to 'activejob')
-rw-r--r--activejob/lib/active_job/queue_adapter.rb6
-rw-r--r--activejob/lib/active_job/queue_adapters.rb8
2 files changed, 9 insertions, 5 deletions
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