From 29738ce97289320c1831bde116cdb7315fec0404 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 25 Sep 2023 14:20:15 +0200 Subject: [PATCH] =?UTF-8?q?Rename=20define=5Fautoloads=5Fin=5Fdir=20?= =?UTF-8?q?=E2=86=92=20define=5Fautoloads=5Ffor=5Fdir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "in" proposition is dubious, because the autoloads themselves are not in the directory. You define them _after_ the entries in the directory. Maybe "for" captures that better. --- lib/zeitwerk/loader.rb | 8 ++++---- lib/zeitwerk/loader/callbacks.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/zeitwerk/loader.rb b/lib/zeitwerk/loader.rb index 9333e18..460a714 100644 --- a/lib/zeitwerk/loader.rb +++ b/lib/zeitwerk/loader.rb @@ -121,7 +121,7 @@ def setup break if @setup actual_roots.each do |root_dir, root_namespace| - define_autoloads_in_dir(root_dir, root_namespace) + define_autoloads_for_dir(root_dir, root_namespace) end on_setup_callbacks.each(&:call) @@ -407,14 +407,14 @@ def all_dirs end # @sig (String, Module) -> void - private def define_autoloads_in_dir(dir, parent) + private def define_autoloads_for_dir(dir, parent) ls(dir) do |basename, abspath| if ruby?(basename) basename.delete_suffix!(".rb") autoload_file(parent, cname_for(basename, abspath), abspath) else if collapse?(abspath) - define_autoloads_in_dir(abspath, parent) + define_autoloads_for_dir(abspath, parent) else autoload_subdir(parent, cname_for(basename, abspath), abspath) end @@ -448,7 +448,7 @@ def all_dirs # For whatever reason the constant that corresponds to this namespace has # already been defined, we have to recurse. log("the namespace #{cpath(parent, cname)} already exists, descending into #{subdir}") if logger - define_autoloads_in_dir(subdir, cget(parent, cname)) + define_autoloads_for_dir(subdir, cget(parent, cname)) end end diff --git a/lib/zeitwerk/loader/callbacks.rb b/lib/zeitwerk/loader/callbacks.rb index 05b1048..a450aeb 100644 --- a/lib/zeitwerk/loader/callbacks.rb +++ b/lib/zeitwerk/loader/callbacks.rb @@ -81,7 +81,7 @@ module Zeitwerk::Loader::Callbacks def on_namespace_loaded(namespace) if dirs = namespace_dirs.delete(real_mod_name(namespace)) dirs.each do |dir| - define_autoloads_in_dir(dir, namespace) + define_autoloads_for_dir(dir, namespace) end end end