diff options
author | Xavier Noria <fxn@hashref.com> | 2019-02-13 19:09:35 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2019-02-13 19:15:04 +0100 |
commit | b4dd69e59b3cb5c34bd58339d5b9a749e2cd82f3 (patch) | |
tree | 00db80c5a3126dffa8ffd3762e471791b2f609f5 /activesupport | |
parent | 4e4b1d05ea820ff777e4734596bb6b0d85495c42 (diff) | |
download | rails-b4dd69e59b3cb5c34bd58339d5b9a749e2cd82f3.tar.gz rails-b4dd69e59b3cb5c34bd58339d5b9a749e2cd82f3.tar.bz2 rails-b4dd69e59b3cb5c34bd58339d5b9a749e2cd82f3.zip |
Refactors a loop
I believe the current style does not clearly communicate that we are
ignoring non-existing autoload paths altogether. Your eyes may even be
looking for an else clause that is easy to miss but that does not exist.
With the early `next` and code comment the loop reads better for my
taste.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/dependencies/zeitwerk_integration.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb index 6892b31a5d..75624bae09 100644 --- a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb +++ b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb @@ -41,12 +41,14 @@ module ActiveSupport def setup_autoloaders Dependencies.autoload_paths.each do |autoload_path| - if File.directory?(autoload_path) - if autoload_once?(autoload_path) - Rails.once_autoloader.push_dir(autoload_path) - else - Rails.autoloader.push_dir(autoload_path) - end + # Zeitwerk only accepts existing directories in `push_dir` to + # prevent misconfigurations. + next unless File.directory?(autoload_path) + + if autoload_once?(autoload_path) + Rails.once_autoloader.push_dir(autoload_path) + else + Rails.autoloader.push_dir(autoload_path) end end |