Class: Zeitwerk::Registry::Inceptions

Inherits:
Object
  • Object
show all
Defined in:
lib/zeitwerk/registry/inceptions.rb

Overview

Loaders know their own inceptions, but there is a use case in which we need to know if a given cpath is an inception globally. This is what this registry is for.

Instance Method Summary collapse

Constructor Details

#initializeInceptions

: () -> void



7
8
9
# File 'lib/zeitwerk/registry/inceptions.rb', line 7

def initialize
  @inceptions = Zeitwerk::Cref::Map.new #: Zeitwerk::Cref::Map[String]
end

Instance Method Details

#clearObject

: () -> void



27
28
29
# File 'lib/zeitwerk/registry/inceptions.rb', line 27

def clear # for tests
  @inceptions.clear
end

#register(cref, abspath) ⇒ Object

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



12
13
14
# File 'lib/zeitwerk/registry/inceptions.rb', line 12

def register(cref, abspath)
  @inceptions[cref] = abspath
end

#registered?(cref) ⇒ Boolean

: (Zeitwerk::Cref) -> String?

Returns:

  • (Boolean)


17
18
19
# File 'lib/zeitwerk/registry/inceptions.rb', line 17

def registered?(cref)
  @inceptions[cref]
end

#unregister(cref) ⇒ Object

: (Zeitwerk::Cref) -> void



22
23
24
# File 'lib/zeitwerk/registry/inceptions.rb', line 22

def unregister(cref)
  @inceptions.delete(cref)
end