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
railties-6.1.7.10 lib/rails/autoloaders.rb
railties-6.1.7.9 lib/rails/autoloaders.rb
railties-6.1.7.8 lib/rails/autoloaders.rb
railties-6.1.7.7 lib/rails/autoloaders.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/autoloaders.rb
railties-6.1.7.6 lib/rails/autoloaders.rb
railties-6.1.7.5 lib/rails/autoloaders.rb
railties-6.1.7.4 lib/rails/autoloaders.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/autoloaders.rb
railties-6.1.7.3 lib/rails/autoloaders.rb
railties-6.1.7.2 lib/rails/autoloaders.rb
railties-6.1.7.1 lib/rails/autoloaders.rb
railties-6.0.6.1 lib/rails/autoloaders.rb
railties-6.1.7 lib/rails/autoloaders.rb
railties-6.0.6 lib/rails/autoloaders.rb
railties-6.1.6.1 lib/rails/autoloaders.rb
railties-6.0.5.1 lib/rails/autoloaders.rb
railties-6.0.5 lib/rails/autoloaders.rb
railties-6.1.6 lib/rails/autoloaders.rb
railties-6.1.5.1 lib/rails/autoloaders.rb