class Zeitwerk::Cref
The constant may or may not exist in ‘mod`.
cref.get
cref.set(value)
cref.path
and have API to manage them. Examples:
Objects represent the constant `cname` in the class or module object `mod`,
This private class encapsulates pairs (mod, cname).
def autoload(abspath)
def autoload(abspath) @mod.autoload(@cname, abspath) end
def autoload?
def autoload? @mod.autoload?(@cname, false) end
def defined?
def defined? @mod.const_defined?(@cname, false) end
def get
def get @mod.const_get(@cname, false) end
def initialize(mod, cname)
objects are also valid.
The type of the first argument is Module because Class < Module, class
def initialize(mod, cname) @mod = mod @cname = cname @path = nil end
def path
def path @path ||= Object == @mod ? @cname.name : "#{real_mod_name(@mod)}::#{@cname.name}".freeze end
def remove
def remove @mod.__send__(:remove_const, @cname) end
def set(value)
def set(value) @mod.const_set(@cname, value) end