Skip to content

Commit

Permalink
Rename define_autoloads_in_dir → define_autoloads_for_dir
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fxn committed Sep 25, 2023
1 parent aa5c587 commit 29738ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/zeitwerk/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/zeitwerk/loader/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29738ce

Please sign in to comment.