Sha256: 5b01ce9943c6d4c587ba744030cc5ee396a5f8a745a40613c6b15e33f0fc5540

Contents?: true

Size: 1.48 KB

Versions: 37

Compression:

Stored size: 1.48 KB

Contents

# 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
    config.active_job.custom_serializers = []

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

    initializer "active_job.custom_serializers" do |app|
      config.after_initialize do
        custom_serializers = app.config.active_job.delete(:custom_serializers)
        ActiveJob::Serializers.add_serializers custom_serializers
      end
    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 do  |k, v|
          k = "#{k}="
          send(k, v) if respond_to? k
        end
      end

      ActiveSupport.on_load(:action_dispatch_integration_test) do
        include ActiveJob::TestHelper
      end

      ActiveSupport.on_load(:active_record) do
        self.destroy_association_async_job = ActiveRecord::DestroyAssociationAsyncJob
      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

Version data entries

37 entries across 37 versions & 4 rubygems

Version Path
activejob-6.1.7.10 lib/active_job/railtie.rb
activejob-6.1.7.9 lib/active_job/railtie.rb
activejob-6.1.7.8 lib/active_job/railtie.rb
activejob-6.1.7.7 lib/active_job/railtie.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-6.1.6.1/lib/active_job/railtie.rb
activejob-6.1.7.6 lib/active_job/railtie.rb
activejob-6.1.7.5 lib/active_job/railtie.rb
activejob-6.1.7.4 lib/active_job/railtie.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activejob-6.1.6.1/lib/active_job/railtie.rb
activejob-6.1.7.3 lib/active_job/railtie.rb
activejob-6.1.7.2 lib/active_job/railtie.rb
activejob-6.1.7.1 lib/active_job/railtie.rb
activejob-6.1.7 lib/active_job/railtie.rb
activejob-6.1.6.1 lib/active_job/railtie.rb
activejob-6.1.6 lib/active_job/railtie.rb
activejob-6.1.5.1 lib/active_job/railtie.rb
activejob-6.1.5 lib/active_job/railtie.rb
activejob-6.1.4.7 lib/active_job/railtie.rb
activejob-6.1.4.6 lib/active_job/railtie.rb
activejob-6.1.4.5 lib/active_job/railtie.rb