diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-03-13 11:03:29 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-03-13 11:03:29 -0300 |
commit | 03148ec96ca7c0f2d461aa242b585e81fe2221d7 (patch) | |
tree | 6c35cbf2372d96b3b12ab154034163035ec4f8af /activejob | |
parent | 99d0c2ac67e9b6593e00f2144e57ad81afba5468 (diff) | |
parent | 9832e17c3ce7a7405eaa1c69da23773b055588c7 (diff) | |
download | rails-03148ec96ca7c0f2d461aa242b585e81fe2221d7.tar.gz rails-03148ec96ca7c0f2d461aa242b585e81fe2221d7.tar.bz2 rails-03148ec96ca7c0f2d461aa242b585e81fe2221d7.zip |
Merge pull request #19311 from square/aj-adapter-lookup
`QueueAdapters` now does lazy lookup
Diffstat (limited to 'activejob')
-rw-r--r-- | activejob/lib/active_job/queue_adapter.rb | 6 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapters.rb | 8 |
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 |