Class: Rails::Autoloaders
- Inherits:
-
Object
- Object
- Rails::Autoloaders
- Includes:
- Enumerable
- Defined in:
- lib/rails/autoloaders.rb,
lib/rails/autoloaders/inflector.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Inflector
Instance Attribute Summary collapse
-
#main ⇒ Object
readonly
Returns the value of attribute main.
-
#once ⇒ Object
readonly
Returns the value of attribute once.
Instance Method Summary collapse
- #each {|main| ... } ⇒ Object
-
#initialize ⇒ Autoloaders
constructor
A new instance of Autoloaders.
- #log! ⇒ Object
- #logger=(logger) ⇒ Object
- #zeitwerk_enabled? ⇒ Boolean
Constructor Details
#initialize ⇒ Autoloaders
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 '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
#main ⇒ Object (readonly)
Returns the value of attribute main.
9 10 11 |
# File 'lib/rails/autoloaders.rb', line 9 def main @main end |
#once ⇒ Object (readonly)
Returns the value of attribute once.
9 10 11 |
# File 'lib/rails/autoloaders.rb', line 9 def once @once end |
Instance Method Details
#each {|main| ... } ⇒ Object
31 32 33 34 |
# File 'lib/rails/autoloaders.rb', line 31 def each yield main yield once end |
#log! ⇒ Object
40 41 42 |
# File 'lib/rails/autoloaders.rb', line 40 def log! each(&:log!) end |
#logger=(logger) ⇒ Object
36 37 38 |
# File 'lib/rails/autoloaders.rb', line 36 def logger=(logger) each { |loader| loader.logger = logger } end |
#zeitwerk_enabled? ⇒ Boolean
44 45 46 |
# File 'lib/rails/autoloaders.rb', line 44 def zeitwerk_enabled? true end |