Skip to content

Commit

Permalink
Make on_file_autoloaded internal
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Sep 17, 2023
1 parent d043718 commit 53c27f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/zeitwerk/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def require(path)
if loader = Zeitwerk::Registry.loader_for(path)
if path.end_with?(".rb")
required = zeitwerk_original_require(path)
loader.on_file_autoloaded(path) if required
loader.__on_file_autoloaded(path) if required
required
else
loader.on_dir_autoloaded(path)
Expand All @@ -39,7 +39,7 @@ def require(path)
if required
abspath = $LOADED_FEATURES.last
if loader = Zeitwerk::Registry.loader_for(abspath)
loader.on_file_autoloaded(abspath)
loader.__on_file_autoloaded(abspath)
end
end
required
Expand Down
4 changes: 2 additions & 2 deletions lib/zeitwerk/loader/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module Zeitwerk::Loader::Callbacks
include Zeitwerk::RealModName
extend Zeitwerk::Internal

# Invoked from our decorated Kernel#require when a managed file is autoloaded.
#
# @private
# @sig (String) -> void
def on_file_autoloaded(file)
internal def on_file_autoloaded(file)
cref = autoloads.delete(file)
cpath = cpath(*cref)

Expand Down
8 changes: 4 additions & 4 deletions test/lib/zeitwerk/test_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TestCallbacks < LoaderTest
module Namespace; end

test "autoloading a file triggers on_file_autoloaded (Object)" do
def loader.on_file_autoloaded(file)
def loader.__on_file_autoloaded(file)
if file == File.expand_path("x.rb")
$on_file_autoloaded_called = true
end
Expand All @@ -22,7 +22,7 @@ def loader.on_file_autoloaded(file)
end

test "autoloading a file triggers on_file_autoloaded (Namespace)" do
def loader.on_file_autoloaded(file)
def loader.__on_file_autoloaded(file)
if file == File.expand_path("x.rb")
$on_file_autoloaded_called = true
end
Expand All @@ -38,7 +38,7 @@ def loader.on_file_autoloaded(file)
end

test "requiring an autoloadable file triggers on_file_autoloaded (Object)" do
def loader.on_file_autoloaded(file)
def loader.__on_file_autoloaded(file)
if file == File.expand_path("y.rb")
$on_file_autoloaded_called = true
end
Expand All @@ -58,7 +58,7 @@ def loader.on_file_autoloaded(file)
end

test "requiring an autoloadable file triggers on_file_autoloaded (Namespace)" do
def loader.on_file_autoloaded(file)
def loader.__on_file_autoloaded(file)
if file == File.expand_path("y.rb")
$on_file_autoloaded_called = true
end
Expand Down

0 comments on commit 53c27f9

Please sign in to comment.