Sha256: 0212fa9dd0ae3d56b134ae685948ffbd3010c745f07ba085e7a15424794a7ce7

Contents?: true

Size: 1.04 KB

Versions: 79

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require "active_support/dependencies/zeitwerk_integration"

module Rails
  module Autoloaders # :nodoc:
    class << self
      include Enumerable

      def main
        if zeitwerk_enabled?
          @main ||= Zeitwerk::Loader.new.tap do |loader|
            loader.tag = "rails.main"
            loader.inflector = ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector
          end
        end
      end

      def once
        if zeitwerk_enabled?
          @once ||= Zeitwerk::Loader.new.tap do |loader|
            loader.tag = "rails.once"
            loader.inflector = ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector
          end
        end
      end

      def each
        if zeitwerk_enabled?
          yield main
          yield once
        end
      end

      def logger=(logger)
        each { |loader| loader.logger = logger }
      end

      def log!
        each(&:log!)
      end

      def zeitwerk_enabled?
        Rails.configuration.autoloader == :zeitwerk
      end
    end
  end
end

Version data entries

79 entries across 77 versions & 8 rubygems

Version Path
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/autoloaders.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/autoloaders.rb
railties-6.0.2.1 lib/rails/autoloaders.rb
railties-6.0.2 lib/rails/autoloaders.rb
railties-6.0.2.rc2 lib/rails/autoloaders.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/autoloaders.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/railties-6.0.1/lib/rails/autoloaders.rb
railties-6.0.2.rc1 lib/rails/autoloaders.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/railties-6.0.1/lib/rails/autoloaders.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/autoloaders.rb
railties-6.0.1 lib/rails/autoloaders.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/railties-6.0.0/lib/rails/autoloaders.rb
railties-6.0.1.rc1 lib/rails/autoloaders.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/railties-6.0.0/lib/rails/autoloaders.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/autoloaders.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/autoloaders.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/autoloaders.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/autoloaders.rb
railties-6.0.0 lib/rails/autoloaders.rb