2014-05-19 04:55:57 -04:00
|
|
|
require 'active_job/queue_adapters/inline_adapter'
|
|
|
|
require 'active_support/core_ext/string/inflections'
|
|
|
|
|
|
|
|
module ActiveJob
|
2014-09-26 13:10:06 -04:00
|
|
|
module QueueAdapter #:nodoc:
|
2014-08-26 16:08:49 -04:00
|
|
|
extend ActiveSupport::Concern
|
2014-05-19 04:55:57 -04:00
|
|
|
|
2014-08-26 16:08:49 -04:00
|
|
|
module ClassMethods
|
|
|
|
mattr_reader(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter }
|
2014-05-19 04:55:57 -04:00
|
|
|
|
2014-09-26 13:10:06 -04:00
|
|
|
# Specify the backend queue provider. The default queue adapter
|
|
|
|
# is the :inline queue. See QueueAdapters for more
|
|
|
|
# information.
|
2014-08-26 16:08:49 -04:00
|
|
|
def queue_adapter=(name_or_adapter)
|
|
|
|
@@queue_adapter = \
|
|
|
|
case name_or_adapter
|
2014-08-29 16:11:17 -04:00
|
|
|
when :test
|
|
|
|
ActiveJob::QueueAdapters::TestAdapter.new
|
2014-08-26 16:08:49 -04:00
|
|
|
when Symbol, String
|
|
|
|
load_adapter(name_or_adapter)
|
|
|
|
when Class
|
|
|
|
name_or_adapter
|
|
|
|
end
|
2014-05-19 04:55:57 -04:00
|
|
|
end
|
2014-08-26 16:08:49 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
def load_adapter(name)
|
|
|
|
"ActiveJob::QueueAdapters::#{name.to_s.camelize}Adapter".constantize
|
|
|
|
end
|
|
|
|
end
|
2014-05-19 04:55:57 -04:00
|
|
|
end
|
2014-09-26 13:10:06 -04:00
|
|
|
end
|