Module: Rails::Autoloaders
- Extended by:
- Enumerable
- Defined in:
- lib/rails/autoloaders.rb
Overview
:nodoc:
Class Method Summary collapse
- .each ⇒ Object
- .log! ⇒ Object
- .logger=(logger) ⇒ Object
- .main ⇒ Object
- .once ⇒ Object
- .zeitwerk_enabled? ⇒ Boolean
Class Method Details
.each ⇒ Object
28 29 30 31 32 33 |
# File 'lib/rails/autoloaders.rb', line 28 def each if zeitwerk_enabled? yield main yield once end end |
.log! ⇒ Object
39 40 41 |
# File 'lib/rails/autoloaders.rb', line 39 def log! each(&:log!) end |
.logger=(logger) ⇒ Object
35 36 37 |
# File 'lib/rails/autoloaders.rb', line 35 def logger=(logger) each { |loader| loader.logger = logger } end |
.main ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/rails/autoloaders.rb', line 10 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 |
.once ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/rails/autoloaders.rb', line 19 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 |
.zeitwerk_enabled? ⇒ Boolean
43 44 45 |
# File 'lib/rails/autoloaders.rb', line 43 def zeitwerk_enabled? Rails.configuration.autoloader == :zeitwerk end |