Module: Zeitwerk::Registry
- Defined in:
- lib/zeitwerk/registry.rb,
lib/zeitwerk/registry/loaders.rb,
lib/zeitwerk/registry/autoloads.rb,
lib/zeitwerk/registry/inceptions.rb,
lib/zeitwerk/registry/explicit_namespaces.rb
Overview
:nodoc: all
Defined Under Namespace
Classes: Autoloads, ExplicitNamespaces, Inceptions, Loaders
Class Attribute Summary collapse
-
.autoloads ⇒ Object
readonly
Maps absolute paths to the loaders responsible for them.
-
.explicit_namespaces ⇒ Object
readonly
: Zeitwerk::Registry::ExplicitNamespaces.
-
.gem_loaders_by_root_file ⇒ Object
readonly
Registers gem loaders to let ‘for_gem` be idempotent in case of reload.
-
.inceptions ⇒ Object
readonly
: Zeitwerk::Registry::Inceptions.
-
.loaders ⇒ Object
readonly
Keeps track of all loaders.
Class Method Summary collapse
-
.loader_for_gem(root_file, namespace:, warn_on_extra_files:) ⇒ Object
This method returns always a loader, the same instance for the same root file.
-
.unregister_loader(loader) ⇒ Object
: (Zeitwerk::Loader) -> void.
Class Attribute Details
.autoloads ⇒ Object (readonly)
Maps absolute paths to the loaders responsible for them.
This information is used by our decorated ‘Kernel#require` to be able to invoke callbacks and autovivify modules.
: Zeitwerk::Registry::Autoloads
31 32 33 |
# File 'lib/zeitwerk/registry.rb', line 31 def autoloads @autoloads end |
.explicit_namespaces ⇒ Object (readonly)
: Zeitwerk::Registry::ExplicitNamespaces
35 36 37 |
# File 'lib/zeitwerk/registry.rb', line 35 def explicit_namespaces @explicit_namespaces end |
.gem_loaders_by_root_file ⇒ Object (readonly)
Registers gem loaders to let ‘for_gem` be idempotent in case of reload.
: Hash[String, Zeitwerk::Loader]
22 23 24 |
# File 'lib/zeitwerk/registry.rb', line 22 def gem_loaders_by_root_file @gem_loaders_by_root_file end |
.inceptions ⇒ Object (readonly)
: Zeitwerk::Registry::Inceptions
39 40 41 |
# File 'lib/zeitwerk/registry.rb', line 39 def inceptions @inceptions end |
.loaders ⇒ Object (readonly)
Keeps track of all loaders. Useful to broadcast messages and to prevent them from being garbage collected.
: Zeitwerk::Registry::Loaders
16 17 18 |
# File 'lib/zeitwerk/registry.rb', line 16 def loaders @loaders end |
Class Method Details
.loader_for_gem(root_file, namespace:, warn_on_extra_files:) ⇒ Object
This method returns always a loader, the same instance for the same root file. That is how Zeitwerk::Loader.for_gem is idempotent.
: (String, namespace: Module, warn_on_extra_files: boolish) -> Zeitwerk::Loader
52 53 54 |
# File 'lib/zeitwerk/registry.rb', line 52 def loader_for_gem(root_file, namespace:, warn_on_extra_files:) gem_loaders_by_root_file[root_file] ||= GemLoader.__new(root_file, namespace: namespace, warn_on_extra_files: warn_on_extra_files) end |
.unregister_loader(loader) ⇒ Object
: (Zeitwerk::Loader) -> void
43 44 45 |
# File 'lib/zeitwerk/registry.rb', line 43 def unregister_loader(loader) gem_loaders_by_root_file.delete_if { |_, l| l == loader } end |