diff options
Diffstat (limited to 'activejob')
-rw-r--r-- | activejob/MIT-LICENSE | 2 | ||||
-rw-r--r-- | activejob/lib/active_job.rb | 2 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapter.rb | 30 |
3 files changed, 14 insertions, 20 deletions
diff --git a/activejob/MIT-LICENSE b/activejob/MIT-LICENSE index daa726b9f0..274211f710 100644 --- a/activejob/MIT-LICENSE +++ b/activejob/MIT-LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2017 David Heinemeier Hansson +Copyright (c) 2014-2018 David Heinemeier Hansson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/activejob/lib/active_job.rb b/activejob/lib/active_job.rb index 1f5bd7b3e9..626abaa767 100644 --- a/activejob/lib/active_job.rb +++ b/activejob/lib/active_job.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true #-- -# Copyright (c) 2014-2017 David Heinemeier Hansson +# Copyright (c) 2014-2018 David Heinemeier Hansson # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index dd05800baf..006a683b85 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -29,28 +29,22 @@ module ActiveJob # Specify the backend queue provider. The default queue adapter # is the +:async+ queue. See QueueAdapters for more # information. - def queue_adapter=(name_or_adapter_or_class) - interpret_adapter(name_or_adapter_or_class) - end - - private - - def interpret_adapter(name_or_adapter_or_class) - case name_or_adapter_or_class - when Symbol, String - assign_adapter(name_or_adapter_or_class.to_s, - ActiveJob::QueueAdapters.lookup(name_or_adapter_or_class).new) + def queue_adapter=(name_or_adapter) + case name_or_adapter + when Symbol, String + queue_adapter = ActiveJob::QueueAdapters.lookup(name_or_adapter).new + assign_adapter(name_or_adapter.to_s, queue_adapter) + else + if queue_adapter?(name_or_adapter) + adapter_name = "#{name_or_adapter.class.name.demodulize.remove('Adapter').underscore}" + assign_adapter(adapter_name, name_or_adapter) else - if queue_adapter?(name_or_adapter_or_class) - adapter_name = "#{name_or_adapter_or_class.class.name.demodulize.remove('Adapter').underscore}" - assign_adapter(adapter_name, - name_or_adapter_or_class) - else - raise ArgumentError - end + raise ArgumentError end end + end + private def assign_adapter(adapter_name, queue_adapter) self._queue_adapter_name = adapter_name self._queue_adapter = queue_adapter |