1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/active_job/queue_adapter.rb
2014-05-19 10:55:57 +02:00

24 lines
No EOL
682 B
Ruby

require 'active_job/queue_adapters/inline_adapter'
require 'active_support/core_ext/string/inflections'
module ActiveJob
module QueueAdapter
mattr_reader(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter }
def queue_adapter=(name_or_adapter)
if name_or_adapter.is_a?(Symbol) || name_or_adapter.is_a?(String)
adapter = load_adapter(name_or_adapter)
else
adapter = name_or_adapter
end
@@queue_adapter = adapter
end
private
def load_adapter(name)
require "active_job/queue_adapters/#{name}_adapter"
"ActiveJob::QueueAdapters::#{name.to_s.camelize}Adapter".constantize
end
end
end