class Zeitwerk::Registry::ExplicitNamespaces

:nodoc: all
**This is a private module.**
loading their constant before setup. This is documented.
Loaders that reopen namespaces owned by other projects are responsible for
The implementation assumes an explicit namespace is managed by one loader.
Once autoloaded, the namespace is unregistered.
expected constants just in time.
subdirectories that conform the namespace and set autoloads for their
loader by calling loader_for. That way, the loader is able to scan the
If the namespace is autoloaded, our const_added callback retrieves its
namespace, it registers it here, associating its cref with itself.
When a loader determines that a certain file should define an explicit
A registry for explicit namespaces.

def clear # for tests

for tests
: () -> void
def clear # for tests
  @loaders.clear
end

def initialize

: () -> void
:nodoc: all
**This is a private module.**

loading their constant before setup. This is documented.
Loaders that reopen namespaces owned by other projects are responsible for
The implementation assumes an explicit namespace is managed by one loader.

Once autoloaded, the namespace is unregistered.

expected constants just in time.
subdirectories that conform the namespace and set autoloads for their
loader by calling loader_for. That way, the loader is able to scan the
If the namespace is autoloaded, our const_added callback retrieves its

namespace, it registers it here, associating its cref with itself.
When a loader determines that a certain file should define an explicit

A registry for explicit namespaces.
def initialize
  # Maps crefs of explicit namespaces with their corresponding loader.
  #
  # Entries are added as the namespaces are found, and removed as they are
  # autoloaded.
  @loaders = Zeitwerk::Cref::Map.new
end

def loader_for(mod, cname)

: (Module, Symbol) -> Zeitwerk::Loader?
def loader_for(mod, cname)
  @loaders.delete_mod_cname(mod, cname)
end

def register(cref, loader)

: (Zeitwerk::Cref, Zeitwerk::Loader) -> void

managed by `loader`.
Registers `cref` as being the constant path of an explicit namespace
def register(cref, loader)
  @loaders[cref] = loader
end

def registered?(cref)

: (Zeitwerk::Cref) -> Zeitwerk::Loader?

This is an internal method only used by the test suite.
def registered?(cref)
  @loaders[cref]
end

def unregister_loader(loader)

: (Zeitwerk::Loader) -> void
def unregister_loader(loader)
  @loaders.delete_by_value(loader)
end