blob: 1bd3f18a74a10ba837b7c183cc4072a2279f068f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# 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 zeitwerk_enabled?
Rails.configuration.autoloader == :zeitwerk
end
end
end
end
|