Module: Zeitwerk::ConstAdded

Defined in:
lib/zeitwerk/core_ext/module.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#const_added(cname) ⇒ Object

: (Symbol) -> void



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/zeitwerk/core_ext/module.rb', line 5

def const_added(cname)
  if loader = Zeitwerk::Registry.explicit_namespaces.loader_for(self, cname)
    namespace = const_get(cname, false)
    cref = Zeitwerk::Cref.new(self, cname)

    unless namespace.is_a?(Module)
      raise Zeitwerk::Error, "#{cref} is expected to be a namespace, should be a class or module (got #{namespace.class})"
    end

    loader.__on_namespace_loaded(cref, namespace)
  end
  super
end