diff options
author | Xavier Noria <fxn@hashref.com> | 2019-02-14 15:12:57 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2019-02-14 22:34:16 -0800 |
commit | 870377915af301c98a54f7f588e077610b2190aa (patch) | |
tree | bb370790a0da8075fef47e2574581c6ba595deb8 /activesupport/lib | |
parent | 16e235126ef0187a93b81ee959a8127097e2f394 (diff) | |
download | rails-870377915af301c98a54f7f588e077610b2190aa.tar.gz rails-870377915af301c98a54f7f588e077610b2190aa.tar.bz2 rails-870377915af301c98a54f7f588e077610b2190aa.zip |
Replace autoloader accessors with Rails.autoloaders.{main,once}
Rails.autoloader and Rails.once_autoloader was just tentative API good
enough for a first patch. Rails.autoloader is singular and does not
convey in its name that there is another autoloader. That might be
confusing, for example if you set a logger and miss traces. On the other
hand, the name `once_autoloader` is very close to being horrible.
Rails.autoloaders.main and Rails.autoloaders.once read better for my
taste, and have a nice symmetry. Also, both "main" and "once" are four
letters long, short and same length.
They are tagged as "rails.main" and "rails.once", respectively.
References #35235.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/dependencies/zeitwerk_integration.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb index 75624bae09..55fc92ee8b 100644 --- a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb +++ b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb @@ -6,7 +6,7 @@ module ActiveSupport module Decorations def clear Dependencies.unload_interlock do - Rails.autoloader.reload + Rails.autoloaders.main.reload end end @@ -19,9 +19,7 @@ module ActiveSupport end def autoloaded_constants - Rails.autoloaders.flat_map do |autoloader| - autoloader.loaded.to_a - end + (Rails.autoloaders.main.loaded + Rails.autoloaders.once.loaded).to_a end def autoloaded?(object) @@ -46,9 +44,9 @@ module ActiveSupport next unless File.directory?(autoload_path) if autoload_once?(autoload_path) - Rails.once_autoloader.push_dir(autoload_path) + Rails.autoloaders.once.push_dir(autoload_path) else - Rails.autoloader.push_dir(autoload_path) + Rails.autoloaders.main.push_dir(autoload_path) end end |