1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activejob/lib/active_job/queue_adapter.rb

33 lines
916 B
Ruby
Raw Normal View History

require 'active_job/queue_adapters/inline_adapter'
require 'active_support/core_ext/string/inflections'
module ActiveJob
module QueueAdapter #:nodoc:
2014-08-26 16:08:49 -04:00
extend ActiveSupport::Concern
2014-08-26 16:08:49 -04:00
module ClassMethods
mattr_reader(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter }
# 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
end
2014-08-26 16:08:49 -04:00
private
def load_adapter(name)
"ActiveJob::QueueAdapters::#{name.to_s.camelize}Adapter".constantize
end
end
end
end