2017-07-09 13:49:52 -04:00
|
|
|
# frozen_string_literal: true
|
2016-08-06 12:40:07 -04:00
|
|
|
require "global_id/railtie"
|
|
|
|
require "active_job"
|
2014-05-21 16:45:56 -04:00
|
|
|
|
|
|
|
module ActiveJob
|
|
|
|
# = Active Job Railtie
|
|
|
|
class Railtie < Rails::Railtie # :nodoc:
|
2014-08-15 16:32:08 -04:00
|
|
|
config.active_job = ActiveSupport::OrderedOptions.new
|
|
|
|
|
2016-08-06 12:40:07 -04:00
|
|
|
initializer "active_job.logger" do
|
2014-05-21 17:10:17 -04:00
|
|
|
ActiveSupport.on_load(:active_job) { self.logger = ::Rails.logger }
|
2014-05-21 16:45:56 -04:00
|
|
|
end
|
2014-08-15 16:32:08 -04:00
|
|
|
|
|
|
|
initializer "active_job.set_configs" do |app|
|
|
|
|
options = app.config.active_job
|
2016-02-05 10:05:48 -05:00
|
|
|
options.queue_adapter ||= :async
|
2014-08-15 16:32:08 -04:00
|
|
|
|
|
|
|
ActiveSupport.on_load(:active_job) do
|
2016-10-28 23:05:58 -04:00
|
|
|
options.each { |k, v| send("#{k}=", v) }
|
2014-08-15 16:32:08 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-26 00:47:01 -05:00
|
|
|
initializer "active_job.set_reloader_hook" do |app|
|
|
|
|
ActiveSupport.on_load(:active_job) do
|
|
|
|
ActiveJob::Callbacks.singleton_class.set_callback(:execute, :around, prepend: true) do |_, inner|
|
|
|
|
app.reloader.wrap do
|
|
|
|
inner.call
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-05-21 16:45:56 -04:00
|
|
|
end
|
2014-08-12 06:53:46 -04:00
|
|
|
end
|