Sha256: bdc354717d6751ce307327a9fff4c23dfa6ac8edbf30e5ee6cdeddde6bc072af

Contents?: true

Size: 724 Bytes

Versions: 2

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

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

      def main
        if zeitwerk_enabled?
          @main ||= Zeitwerk::Loader.new.tap { |loader| loader.tag = "rails.main" }
        end
      end

      def once
        if zeitwerk_enabled?
          @once ||= Zeitwerk::Loader.new.tap { |loader| loader.tag = "rails.once" }
        end
      end

      def each
        if zeitwerk_enabled?
          yield main
          yield once
        end
      end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railties-6.0.0.beta3 lib/rails/autoloaders.rb
railties-6.0.0.beta2 lib/rails/autoloaders.rb