1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/autoloaders.rb
Xavier Noria 0d523d8365 Drops support for classic mode
This starts a series of patches in which we drop classic mode. The final
result no longer has a const_missing callback, there is no hook/unhook,
and so on.

So, in this patch we remove the ability of configuring classic, but some
of the code that remains will be further refactored.
2021-03-08 05:30:11 +01:00

49 lines
1 KiB
Ruby

# frozen_string_literal: true
require "active_support/dependencies/zeitwerk_integration"
require "zeitwerk"
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 log!
each(&:log!)
end
def zeitwerk_enabled?
true
end
end
end
end