aboutsummaryrefslogblamecommitdiffstats
path: root/activejob/lib/active_job/railtie.rb
blob: 7b0742a6d28970e762e30096b7d393730541878a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                             
 

                           



                                          

                                                         
                                      
                                                                         
       


                                                 
                                      

                                           
                                                


         








                                                                                                         
     
   
# frozen_string_literal: true

require "global_id/railtie"
require "active_job"

module ActiveJob
  # = Active Job Railtie
  class Railtie < Rails::Railtie # :nodoc:
    config.active_job = ActiveSupport::OrderedOptions.new

    initializer "active_job.logger" do
      ActiveSupport.on_load(:active_job) { self.logger = ::Rails.logger }
    end

    initializer "active_job.set_configs" do |app|
      options = app.config.active_job
      options.queue_adapter ||= :async

      ActiveSupport.on_load(:active_job) do
        options.each { |k, v| send("#{k}=", v) }
      end
    end

    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
  end
end