Skip to content

Commit 9f93a06

Browse files
committed
Mark private methods individually in Zeitwerk::Loader
1 parent 4acfd42 commit 9f93a06

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

lib/zeitwerk/loader.rb

+11-13
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,8 @@ def all_dirs
324324
end
325325
end
326326

327-
private # -------------------------------------------------------------------------------------
328-
329327
# @sig (String, Module) -> void
330-
def set_autoloads_in_dir(dir, parent)
328+
private def set_autoloads_in_dir(dir, parent)
331329
ls(dir) do |basename, abspath|
332330
begin
333331
if ruby?(basename)
@@ -362,7 +360,7 @@ def set_autoloads_in_dir(dir, parent)
362360
end
363361

364362
# @sig (Module, Symbol, String) -> void
365-
def autoload_subdir(parent, cname, subdir)
363+
private def autoload_subdir(parent, cname, subdir)
366364
if autoload_path = autoload_path_set_by_me_for?(parent, cname)
367365
cpath = cpath(parent, cname)
368366
if ruby?(autoload_path)
@@ -392,7 +390,7 @@ def autoload_subdir(parent, cname, subdir)
392390
end
393391

394392
# @sig (Module, Symbol, String) -> void
395-
def autoload_file(parent, cname, file)
393+
private def autoload_file(parent, cname, file)
396394
if autoload_path = strict_autoload_path(parent, cname) || Registry.inception?(cpath(parent, cname))
397395
# First autoload for a Ruby file wins, just ignore subsequent ones.
398396
if ruby?(autoload_path)
@@ -418,7 +416,7 @@ def autoload_file(parent, cname, file)
418416
# the file where we've found the namespace is explicitly defined.
419417
#
420418
# @sig (dir: String, file: String, parent: Module, cname: Symbol) -> void
421-
def promote_namespace_from_implicit_to_explicit(dir:, file:, parent:, cname:)
419+
private def promote_namespace_from_implicit_to_explicit(dir:, file:, parent:, cname:)
422420
autoloads.delete(dir)
423421
Registry.unregister_autoload(dir)
424422

@@ -429,7 +427,7 @@ def promote_namespace_from_implicit_to_explicit(dir:, file:, parent:, cname:)
429427
end
430428

431429
# @sig (Module, Symbol, String) -> void
432-
def set_autoload(parent, cname, abspath)
430+
private def set_autoload(parent, cname, abspath)
433431
parent.autoload(cname, abspath)
434432

435433
if logger
@@ -450,7 +448,7 @@ def set_autoload(parent, cname, abspath)
450448
end
451449

452450
# @sig (Module, Symbol) -> String?
453-
def autoload_path_set_by_me_for?(parent, cname)
451+
private def autoload_path_set_by_me_for?(parent, cname)
454452
if autoload_path = strict_autoload_path(parent, cname)
455453
autoload_path if autoloads.key?(autoload_path)
456454
else
@@ -459,12 +457,12 @@ def autoload_path_set_by_me_for?(parent, cname)
459457
end
460458

461459
# @sig (String) -> void
462-
def register_explicit_namespace(cpath)
460+
private def register_explicit_namespace(cpath)
463461
ExplicitNamespace.__register(cpath, self)
464462
end
465463

466464
# @sig (String) -> void
467-
def raise_if_conflicting_directory(dir)
465+
private def raise_if_conflicting_directory(dir)
468466
MUTEX.synchronize do
469467
dir_slash = dir + "/"
470468

@@ -489,20 +487,20 @@ def raise_if_conflicting_directory(dir)
489487
end
490488

491489
# @sig (String, Object, String) -> void
492-
def run_on_unload_callbacks(cpath, value, abspath)
490+
private def run_on_unload_callbacks(cpath, value, abspath)
493491
# Order matters. If present, run the most specific one.
494492
on_unload_callbacks[cpath]&.each { |c| c.call(value, abspath) }
495493
on_unload_callbacks[:ANY]&.each { |c| c.call(cpath, value, abspath) }
496494
end
497495

498496
# @sig (Module, Symbol) -> void
499-
def unload_autoload(parent, cname)
497+
private def unload_autoload(parent, cname)
500498
crem(parent, cname)
501499
log("autoload for #{cpath(parent, cname)} removed") if logger
502500
end
503501

504502
# @sig (Module, Symbol) -> void
505-
def unload_cref(parent, cname)
503+
private def unload_cref(parent, cname)
506504
# Let's optimistically remove_const. The way we use it, this is going to
507505
# succeed always if all is good.
508506
crem(parent, cname)

0 commit comments

Comments
 (0)