Class: Rails::Autoloaders

Inherits:
Object show all
Includes:
Enumerable
Defined in:
railties/lib/rails/autoloaders.rb,
railties/lib/rails/autoloaders/inflector.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Inflector

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#as_json

Constructor Details

#initializeAutoloaders

Returns a new instance of Autoloaders.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'railties/lib/rails/autoloaders.rb', line 11

def initialize
  # This `require` delays loading the library on purpose.
  #
  # In Rails 7.0.0, railties/lib/rails.rb loaded Zeitwerk as a side-effect,
  # but a couple of edge cases related to Bundler and Bootsnap showed up.
  # They had to do with order of decoration of `Kernel#require`, something
  # the three of them do.
  #
  # Delaying this `require` up to this point is a convenient trade-off.
  require "zeitwerk"

  @main = Zeitwerk::Loader.new
  @main.tag = "rails.main"
  @main.inflector = Inflector

  @once = Zeitwerk::Loader.new
  @once.tag = "rails.once"
  @once.inflector = Inflector
end

Instance Attribute Details

#mainObject (readonly)

Returns the value of attribute main



9
10
11
# File 'railties/lib/rails/autoloaders.rb', line 9

def main
  @main
end

#onceObject (readonly)

Returns the value of attribute once



9
10
11
# File 'railties/lib/rails/autoloaders.rb', line 9

def once
  @once
end

Instance Method Details

#each {|main| ... } ⇒ Object

Yields:



31
32
33
34
# File 'railties/lib/rails/autoloaders.rb', line 31

def each
  yield main
  yield once
end

#log!Object



40
41
42
# File 'railties/lib/rails/autoloaders.rb', line 40

def log!
  each(&:log!)
end

#logger=(logger) ⇒ Object



36
37
38
# File 'railties/lib/rails/autoloaders.rb', line 36

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

#zeitwerk_enabled?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'railties/lib/rails/autoloaders.rb', line 44

def zeitwerk_enabled?
  true
end