zeitwerk 2.7.2 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ module Zeitwerk
18
18
  include Config
19
19
  include EagerLoad
20
20
 
21
- MUTEX = Mutex.new
21
+ MUTEX = Mutex.new #: Mutex
22
22
  private_constant :MUTEX
23
23
 
24
24
  # Maps absolute paths for which an autoload has been set ---and not
@@ -28,7 +28,7 @@ module Zeitwerk
28
28
  # "/Users/fxn/blog/app/models/hotel/pricing.rb" => #<Zeitwerk::Cref:... @mod=Hotel, @cname=:Pricing, ...>,
29
29
  # ...
30
30
  #
31
- # @sig Hash[String, Zeitwerk::Cref]
31
+ #: Hash[String, Zeitwerk::Cref]
32
32
  attr_reader :autoloads
33
33
  internal :autoloads
34
34
 
@@ -49,10 +49,10 @@ module Zeitwerk
49
49
  # the inceptions just in case.
50
50
  #
51
51
  # This map keeps track of pairs (cref, autoload_path) found by the loader.
52
- # The module Zeitwerk::Registry::Inceptions, on the other hand, acts as a
52
+ # The object Zeitwerk::Registry.inceptions, on the other hand, acts as a
53
53
  # global registry for them.
54
54
  #
55
- # @sig Zeitwerk::Cref::Map[String]
55
+ #: Zeitwerk::Cref::Map[String]
56
56
  attr_reader :inceptions
57
57
  internal :inceptions
58
58
 
@@ -62,7 +62,7 @@ module Zeitwerk
62
62
  # Files are removed as they are autoloaded, but directories need to wait due
63
63
  # to concurrency (see why in Zeitwerk::Loader::Callbacks#on_dir_autoloaded).
64
64
  #
65
- # @sig Array[String]
65
+ #: Array[String]
66
66
  attr_reader :autoloaded_dirs
67
67
  internal :autoloaded_dirs
68
68
 
@@ -72,7 +72,7 @@ module Zeitwerk
72
72
  # On unload, the autoload paths are passed to callbacks, files deleted from
73
73
  # $LOADED_FEATURES, and the crefs are deleted.
74
74
  #
75
- # @sig Hash[String, Zeitwerk::Cref]
75
+ #: Hash[String, Zeitwerk::Cref]
76
76
  attr_reader :to_unload
77
77
  internal :to_unload
78
78
 
@@ -81,7 +81,7 @@ module Zeitwerk
81
81
  # When these crefs get defined we know their children are spread over those
82
82
  # directories. We'll visit them to set up the corresponding autoloads.
83
83
  #
84
- # @sig Zeitwerk::Cref::Map[String]
84
+ #: Zeitwerk::Cref::Map[String]
85
85
  attr_reader :namespace_dirs
86
86
  internal :namespace_dirs
87
87
 
@@ -92,15 +92,15 @@ module Zeitwerk
92
92
  # loader has only scanned the top-level, `shadowed_files` does not have the
93
93
  # shadowed files that may exist deep in the project tree.
94
94
  #
95
- # @sig Set[String]
95
+ #: Set[String]
96
96
  attr_reader :shadowed_files
97
97
  internal :shadowed_files
98
98
 
99
- # @sig Mutex
99
+ #: Mutex
100
100
  attr_reader :mutex
101
101
  private :mutex
102
102
 
103
- # @sig Monitor
103
+ #: Monitor
104
104
  attr_reader :dirs_autoload_monitor
105
105
  private :dirs_autoload_monitor
106
106
 
@@ -119,12 +119,12 @@ module Zeitwerk
119
119
  @mutex = Mutex.new
120
120
  @dirs_autoload_monitor = Monitor.new
121
121
 
122
- Registry.register_loader(self)
122
+ Registry.loaders.register(self)
123
123
  end
124
124
 
125
125
  # Sets autoloads in the root namespaces.
126
126
  #
127
- # @sig () -> void
127
+ #: () -> void
128
128
  def setup
129
129
  mutex.synchronize do
130
130
  break if @setup
@@ -150,7 +150,7 @@ module Zeitwerk
150
150
  # means `unload` + `setup`. This one is available to be used together with
151
151
  # `unregister`, which is undocumented too.
152
152
  #
153
- # @sig () -> void
153
+ #: () -> void
154
154
  def unload
155
155
  mutex.synchronize do
156
156
  raise SetupRequired unless @setup
@@ -216,7 +216,7 @@ module Zeitwerk
216
216
  unregister_inceptions
217
217
  unregister_explicit_namespaces
218
218
 
219
- Registry.on_unload(self)
219
+ Registry.autoloads.unregister_loader(self)
220
220
 
221
221
  @setup = false
222
222
  @eager_loaded = false
@@ -229,8 +229,7 @@ module Zeitwerk
229
229
  # This method is not thread-safe, please see how this can be achieved by
230
230
  # client code in the README of the project.
231
231
  #
232
- # @raise [Zeitwerk::Error]
233
- # @sig () -> void
232
+ #: () -> void ! Zeitwerk::Error
234
233
  def reload
235
234
  raise ReloadingDisabledError unless reloading_enabled?
236
235
  raise SetupRequired unless @setup
@@ -244,7 +243,7 @@ module Zeitwerk
244
243
  # Returns a hash that maps the absolute paths of the managed files and
245
244
  # directories to their respective expected constant paths.
246
245
  #
247
- # @sig () -> Hash[String, String]
246
+ #: () -> Hash[String, String]
248
247
  def all_expected_cpaths
249
248
  result = {}
250
249
 
@@ -274,7 +273,7 @@ module Zeitwerk
274
273
  result
275
274
  end
276
275
 
277
- # @sig (String | Pathname) -> String?
276
+ #: (String | Pathname) -> String?
278
277
  def cpath_expected_at(path)
279
278
  abspath = File.expand_path(path)
280
279
 
@@ -304,7 +303,7 @@ module Zeitwerk
304
303
  basename = File.basename(dir)
305
304
  return if hidden?(basename)
306
305
 
307
- paths << [basename, abspath] unless collapse?(dir)
306
+ paths << [basename, dir] unless collapse?(dir)
308
307
  end
309
308
 
310
309
  return unless root_namespace
@@ -312,7 +311,7 @@ module Zeitwerk
312
311
  if paths.empty?
313
312
  real_mod_name(root_namespace)
314
313
  else
315
- cnames = paths.reverse_each.map { |b, a| cname_for(b, a) }
314
+ cnames = paths.reverse_each.map { cname_for(_1, _2) }
316
315
 
317
316
  if root_namespace == Object
318
317
  cnames.join("::")
@@ -328,7 +327,7 @@ module Zeitwerk
328
327
  # This is an undocumented method that I wrote to help transition from the
329
328
  # classic autoloader in Rails. Its usage was removed from Rails in 7.0.
330
329
  #
331
- # @sig (String) -> bool
330
+ #: (String) -> bool
332
331
  def unloadable_cpath?(cpath)
333
332
  unloadable_cpaths.include?(cpath)
334
333
  end
@@ -339,7 +338,7 @@ module Zeitwerk
339
338
  # This is an undocumented method that I wrote to help transition from the
340
339
  # classic autoloader in Rails. Its usage was removed from Rails in 7.0.
341
340
  #
342
- # @sig () -> Array[String]
341
+ #: () -> Array[String]
343
342
  def unloadable_cpaths
344
343
  to_unload.values.map(&:path)
345
344
  end
@@ -347,17 +346,19 @@ module Zeitwerk
347
346
  # This is a dangerous method.
348
347
  #
349
348
  # @experimental
350
- # @sig () -> void
349
+ #: () -> void
351
350
  def unregister
352
351
  unregister_inceptions
353
352
  unregister_explicit_namespaces
353
+ Registry.loaders.unregister(self)
354
+ Registry.autoloads.unregister_loader(self)
354
355
  Registry.unregister_loader(self)
355
356
  end
356
357
 
357
358
  # The return value of this predicate is only meaningful if the loader has
358
359
  # scanned the file. This is the case in the spots where we use it.
359
360
  #
360
- # @sig (String) -> Boolean
361
+ #: (String) -> bool
361
362
  internal def shadowed_file?(file)
362
363
  shadowed_files.member?(file)
363
364
  end
@@ -367,7 +368,7 @@ module Zeitwerk
367
368
  class << self
368
369
  include RealModName
369
370
 
370
- # @sig #call | #debug | nil
371
+ #: call(String) -> void | debug(String) -> void | nil
371
372
  attr_accessor :default_logger
372
373
 
373
374
  # This is a shortcut for
@@ -385,7 +386,7 @@ module Zeitwerk
385
386
  # This method returns a subclass of Zeitwerk::Loader, but the exact type
386
387
  # is private, client code can only rely on the interface.
387
388
  #
388
- # @sig (bool) -> Zeitwerk::GemLoader
389
+ #: (?warn_on_extra_files: boolish) -> Zeitwerk::GemLoader
389
390
  def for_gem(warn_on_extra_files: true)
390
391
  called_from = caller_locations(1, 1).first.path
391
392
  Registry.loader_for_gem(called_from, namespace: Object, warn_on_extra_files: warn_on_extra_files)
@@ -406,7 +407,7 @@ module Zeitwerk
406
407
  # This method returns a subclass of Zeitwerk::Loader, but the exact type
407
408
  # is private, client code can only rely on the interface.
408
409
  #
409
- # @sig (bool) -> Zeitwerk::GemLoader
410
+ #: (Module) -> Zeitwerk::GemLoader
410
411
  def for_gem_extension(namespace)
411
412
  unless namespace.is_a?(Module) # Note that Class < Module.
412
413
  raise Zeitwerk::Error, "#{namespace.inspect} is not a class or module object, should be"
@@ -423,7 +424,7 @@ module Zeitwerk
423
424
  # Broadcasts `eager_load` to all loaders. Those that have not been setup
424
425
  # are skipped.
425
426
  #
426
- # @sig () -> void
427
+ #: () -> void
427
428
  def eager_load_all
428
429
  Registry.loaders.each do |loader|
429
430
  begin
@@ -437,7 +438,7 @@ module Zeitwerk
437
438
  # Broadcasts `eager_load_namespace` to all loaders. Those that have not
438
439
  # been setup are skipped.
439
440
  #
440
- # @sig (Module) -> void
441
+ #: (Module) -> void
441
442
  def eager_load_namespace(mod)
442
443
  Registry.loaders.each do |loader|
443
444
  begin
@@ -451,13 +452,17 @@ module Zeitwerk
451
452
  # Returns an array with the absolute paths of the root directories of all
452
453
  # registered loaders. This is a read-only collection.
453
454
  #
454
- # @sig () -> Array[String]
455
+ #: () -> Array[String]
455
456
  def all_dirs
456
- Registry.loaders.flat_map(&:dirs).freeze
457
+ dirs = []
458
+ Registry.loaders.each do |loader|
459
+ dirs.concat(loader.dirs)
460
+ end
461
+ dirs.freeze
457
462
  end
458
463
  end
459
464
 
460
- # @sig (String, Module) -> void
465
+ #: (String, Module) -> void
461
466
  private def define_autoloads_for_dir(dir, parent)
462
467
  ls(dir) do |basename, abspath, ftype|
463
468
  if ftype == :file
@@ -475,7 +480,7 @@ module Zeitwerk
475
480
  end
476
481
  end
477
482
 
478
- # @sig (Module, Symbol, String) -> void
483
+ #: (Zeitwerk::Cref, String) -> void
479
484
  private def autoload_subdir(cref, subdir)
480
485
  if autoload_path = autoload_path_set_by_me_for?(cref)
481
486
  if ruby?(autoload_path)
@@ -504,9 +509,9 @@ module Zeitwerk
504
509
  end
505
510
  end
506
511
 
507
- # @sig (Module, Symbol, String) -> void
512
+ #: (Zeitwerk::Cref, String) -> void
508
513
  private def autoload_file(cref, file)
509
- if autoload_path = cref.autoload? || Registry::Inceptions.registered?(cref)
514
+ if autoload_path = cref.autoload? || Registry.inceptions.registered?(cref)
510
515
  # First autoload for a Ruby file wins, just ignore subsequent ones.
511
516
  if ruby?(autoload_path)
512
517
  shadowed_files << file
@@ -525,10 +530,10 @@ module Zeitwerk
525
530
  # `dir` is the directory that would have autovivified a namespace. `file` is
526
531
  # the file where we've found the namespace is explicitly defined.
527
532
  #
528
- # @sig (dir: String, file: String, cref: Zeitwerk::Cref) -> void
533
+ #: (dir: String, file: String, cref: Zeitwerk::Cref) -> void
529
534
  private def promote_namespace_from_implicit_to_explicit(dir:, file:, cref:)
530
535
  autoloads.delete(dir)
531
- Registry.unregister_autoload(dir)
536
+ Registry.autoloads.unregister(dir)
532
537
 
533
538
  log("earlier autoload for #{cref} discarded, it is actually an explicit namespace defined in #{file}") if logger
534
539
 
@@ -538,7 +543,7 @@ module Zeitwerk
538
543
  register_explicit_namespace(cref)
539
544
  end
540
545
 
541
- # @sig (Module, Symbol, String) -> void
546
+ #: (Zeitwerk::Cref, String) -> void
542
547
  private def define_autoload(cref, abspath)
543
548
  cref.autoload(abspath)
544
549
 
@@ -551,12 +556,12 @@ module Zeitwerk
551
556
  end
552
557
 
553
558
  autoloads[abspath] = cref
554
- Registry.register_autoload(self, abspath)
559
+ Registry.autoloads.register(abspath, self)
555
560
 
556
561
  register_inception(cref, abspath) unless cref.autoload?
557
562
  end
558
563
 
559
- # @sig (Module, Symbol) -> String?
564
+ #: (Zeitwerk::Cref) -> String?
560
565
  private def autoload_path_set_by_me_for?(cref)
561
566
  if autoload_path = cref.autoload?
562
567
  autoload_path if autoloads.key?(autoload_path)
@@ -565,31 +570,31 @@ module Zeitwerk
565
570
  end
566
571
  end
567
572
 
568
- # @sig (Zeitwerk::Cref) -> void
573
+ #: (Zeitwerk::Cref) -> void
569
574
  private def register_explicit_namespace(cref)
570
- Registry::ExplicitNamespaces.__register(cref, self)
575
+ Registry.explicit_namespaces.register(cref, self)
571
576
  end
572
577
 
573
- # @sig () -> void
578
+ #: () -> void
574
579
  private def unregister_explicit_namespaces
575
- Registry::ExplicitNamespaces.__unregister_loader(self)
580
+ Registry.explicit_namespaces.unregister_loader(self)
576
581
  end
577
582
 
578
- # @sig (Zeitwerk::Cref, String) -> void
583
+ #: (Zeitwerk::Cref, String) -> void
579
584
  private def register_inception(cref, abspath)
580
585
  inceptions[cref] = abspath
581
- Registry::Inceptions.register(cref, abspath)
586
+ Registry.inceptions.register(cref, abspath)
582
587
  end
583
588
 
584
- # @sig () -> void
589
+ #: () -> void
585
590
  private def unregister_inceptions
586
591
  inceptions.each_key do |cref|
587
- Registry::Inceptions.unregister(cref)
592
+ Registry.inceptions.unregister(cref)
588
593
  end
589
594
  inceptions.clear
590
595
  end
591
596
 
592
- # @sig (String) -> void
597
+ #: (String) -> void
593
598
  private def raise_if_conflicting_directory(dir)
594
599
  MUTEX.synchronize do
595
600
  dir_slash = dir + "/"
@@ -613,20 +618,20 @@ module Zeitwerk
613
618
  end
614
619
  end
615
620
 
616
- # @sig (String, top, String) -> void
621
+ #: (String, top, String) -> void
617
622
  private def run_on_unload_callbacks(cref, value, abspath)
618
623
  # Order matters. If present, run the most specific one.
619
624
  on_unload_callbacks[cref.path]&.each { |c| c.call(value, abspath) }
620
625
  on_unload_callbacks[:ANY]&.each { |c| c.call(cref.path, value, abspath) }
621
626
  end
622
627
 
623
- # @sig (Module, Symbol) -> void
628
+ #: (Zeitwerk::Cref) -> void
624
629
  private def unload_autoload(cref)
625
630
  cref.remove
626
631
  log("autoload for #{cref} removed") if logger
627
632
  end
628
633
 
629
- # @sig (Module, Symbol) -> void
634
+ #: (Zeitwerk::Cref) -> void
630
635
  private def unload_cref(cref)
631
636
  # Let's optimistically remove_const. The way we use it, this is going to
632
637
  # succeed always if all is good.
@@ -1,5 +1,5 @@
1
1
  class Zeitwerk::NullInflector
2
- # @sig (String, String) -> String
2
+ #: (String, String) -> String
3
3
  def camelize(basename, _abspath)
4
4
  basename
5
5
  end
@@ -1,15 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk::RealModName
4
+ #: UnboundMethod
4
5
  UNBOUND_METHOD_MODULE_NAME = Module.instance_method(:name)
5
6
  private_constant :UNBOUND_METHOD_MODULE_NAME
6
7
 
7
- # Returns the real name of the class or module, as set after the first
8
- # constant to which it was assigned (or nil).
8
+ # Returns the real name of the class or module.
9
9
  #
10
- # The name method can be overridden, hence the indirection in this method.
10
+ # We need this indirection becasue the `name` method can be overridden, and
11
+ # because in practice what we really need is the constant paths of modules
12
+ # with a permanent name, not so much what the user considers to be the name of
13
+ # a certain class or module of theirs.
11
14
  #
12
- # @sig (Module) -> String?
15
+ #: (Module) -> String?
13
16
  def real_mod_name(mod)
14
17
  UNBOUND_METHOD_MODULE_NAME.bind_call(mod)
15
18
  end
@@ -0,0 +1,38 @@
1
+ module Zeitwerk::Registry
2
+ class Autoloads # :nodoc:
3
+ #: () -> void
4
+ def initialize
5
+ @autoloads = {} #: Hash[String, Zeitwerk::Loader]
6
+ end
7
+
8
+ #: (String, Zeitwerk::Loader) -> Zeitwerk::Loader
9
+ def register(abspath, loader)
10
+ @autoloads[abspath] = loader
11
+ end
12
+
13
+ #: (String) -> Zeitwerk::Loader?
14
+ def registered?(path)
15
+ @autoloads[path]
16
+ end
17
+
18
+ #: (String) -> Zeitwerk::Loader?
19
+ def unregister(abspath)
20
+ @autoloads.delete(abspath)
21
+ end
22
+
23
+ #: (Zeitwerk::Loader) -> void
24
+ def unregister_loader(loader)
25
+ @autoloads.delete_if { _2 == loader }
26
+ end
27
+
28
+ #: () -> bool
29
+ def empty? # for tests
30
+ @autoloads.empty?
31
+ end
32
+
33
+ #: () -> void
34
+ def clear # for tests
35
+ @autoloads.clear
36
+ end
37
+ end
38
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk::Registry
4
- # This module is a registry for explicit namespaces.
4
+ # A registry for explicit namespaces.
5
5
  #
6
6
  # When a loader determines that a certain file should define an explicit
7
7
  # namespace, it registers it here, associating its cref with itself.
@@ -16,49 +16,46 @@ module Zeitwerk::Registry
16
16
  # The implementation assumes an explicit namespace is managed by one loader.
17
17
  # Loaders that reopen namespaces owned by other projects are responsible for
18
18
  # loading their constant before setup. This is documented.
19
- module ExplicitNamespaces # :nodoc: all
20
- # Maps crefs of explicit namespaces with their corresponding loader.
21
- #
22
- # Entries are added as the namespaces are found, and removed as they are
23
- # autoloaded.
24
- #
25
- # @sig Zeitwerk::Cref::Map[Zeitwerk::Loader]
26
- @loaders = Zeitwerk::Cref::Map.new
27
-
28
- class << self
29
- extend Zeitwerk::Internal
30
-
31
- # Registers `cref` as being the constant path of an explicit namespace
32
- # managed by `loader`.
19
+ #
20
+ # **This is a private module.**
21
+ class ExplicitNamespaces # :nodoc: all
22
+ #: () -> void
23
+ def initialize
24
+ # Maps crefs of explicit namespaces with their corresponding loader.
33
25
  #
34
- # @sig (Zeitwerk::Cref, Zeitwerk::Loader) -> void
35
- internal def register(cref, loader)
36
- @loaders[cref] = loader
37
- end
26
+ # Entries are added as the namespaces are found, and removed as they are
27
+ # autoloaded.
28
+ @loaders = Zeitwerk::Cref::Map.new
29
+ end
38
30
 
39
- # @sig (Module, Symbol) -> Zeitwerk::Loader?
40
- internal def loader_for(mod, cname)
41
- @loaders.delete_mod_cname(mod, cname)
42
- end
31
+ # Registers `cref` as being the constant path of an explicit namespace
32
+ # managed by `loader`.
33
+ #
34
+ #: (Zeitwerk::Cref, Zeitwerk::Loader) -> void
35
+ def register(cref, loader)
36
+ @loaders[cref] = loader
37
+ end
43
38
 
44
- # @sig (Zeitwerk::Loader) -> void
45
- internal def unregister_loader(loader)
46
- @loaders.delete_by_value(loader)
47
- end
39
+ #: (Module, Symbol) -> Zeitwerk::Loader?
40
+ def loader_for(mod, cname)
41
+ @loaders.delete_mod_cname(mod, cname)
42
+ end
48
43
 
49
- # This is an internal method only used by the test suite.
50
- #
51
- # @sig (Symbol | String) -> Zeitwerk::Loader?
52
- internal def registered?(cref)
53
- @loaders[cref]
54
- end
44
+ #: (Zeitwerk::Loader) -> void
45
+ def unregister_loader(loader)
46
+ @loaders.delete_by_value(loader)
47
+ end
55
48
 
56
- # This is an internal method only used by the test suite.
57
- #
58
- # @sig () -> void
59
- internal def clear
60
- @loaders.clear
61
- end
49
+ # This is an internal method only used by the test suite.
50
+ #
51
+ #: (Zeitwerk::Cref) -> Zeitwerk::Loader?
52
+ def registered?(cref)
53
+ @loaders[cref]
54
+ end
55
+
56
+ #: () -> void
57
+ def clear # for tests
58
+ @loaders.clear
62
59
  end
63
60
  end
64
61
  end
@@ -2,30 +2,30 @@ module Zeitwerk::Registry
2
2
  # Loaders know their own inceptions, but there is a use case in which we need
3
3
  # to know if a given cpath is an inception globally. This is what this
4
4
  # registry is for.
5
- module Inceptions # :nodoc: all
6
- # @sig Zeitwerk::Cref::Map[String]
7
- @inceptions = Zeitwerk::Cref::Map.new
5
+ class Inceptions # :nodoc:
6
+ #: () -> void
7
+ def initialize
8
+ @inceptions = Zeitwerk::Cref::Map.new #: Zeitwerk::Cref::Map[String]
9
+ end
8
10
 
9
- class << self
10
- # @sig (Zeitwerk::Cref, String) -> void
11
- def register(cref, autoload_path)
12
- @inceptions[cref] = autoload_path
13
- end
11
+ #: (Zeitwerk::Cref, String) -> void
12
+ def register(cref, abspath)
13
+ @inceptions[cref] = abspath
14
+ end
14
15
 
15
- # @sig (String) -> String?
16
- def registered?(cref)
17
- @inceptions[cref]
18
- end
16
+ #: (Zeitwerk::Cref) -> String?
17
+ def registered?(cref)
18
+ @inceptions[cref]
19
+ end
19
20
 
20
- # @sig (String) -> void
21
- def unregister(cref)
22
- @inceptions.delete(cref)
23
- end
21
+ #: (Zeitwerk::Cref) -> void
22
+ def unregister(cref)
23
+ @inceptions.delete(cref)
24
+ end
24
25
 
25
- # @sig () -> void
26
- def clear # for tests
27
- @inceptions.clear
28
- end
26
+ #: () -> void
27
+ def clear # for tests
28
+ @inceptions.clear
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,33 @@
1
+ module Zeitwerk::Registry
2
+ class Loaders # :nodoc:
3
+ #: () -> void
4
+ def initialize
5
+ @loaders = [] #: Array[Zeitwerk::Loader]
6
+ end
7
+
8
+ #: ({ (Zeitwerk::Loader) -> void }) -> void
9
+ def each(&block)
10
+ @loaders.each(&block)
11
+ end
12
+
13
+ #: (Zeitwerk::Loader) -> void
14
+ def register(loader)
15
+ @loaders << loader
16
+ end
17
+
18
+ #: (Zeitwerk::Loader) -> Zeitwerk::Loader?
19
+ def unregister(loader)
20
+ @loaders.delete(loader)
21
+ end
22
+
23
+ #: (Zeitwerk::Loader) -> bool
24
+ def registered?(loader) # for tests
25
+ @loaders.include?(loader)
26
+ end
27
+
28
+ #: () -> void
29
+ def clear # for tests
30
+ @loaders.clear
31
+ end
32
+ end
33
+ end