Class: Zeitwerk::Loader::ConstantPathValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/zeitwerk/loader/constant_path_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate!(possible_cpath) ⇒ Object

Technically, this validation works with symbols, but API boundary restricts input to strings, so we assume strings, and we test strings.

: (String) -> String ! NameError



10
11
12
13
14
15
16
# File 'lib/zeitwerk/loader/constant_path_validator.rb', line 10

def validate!(possible_cpath)
  # We do this before validating because as of this writing, TruffleRuby
  # raises TypeError if the argument has leading colons.
  possible_cpath = possible_cpath.delete_prefix('::')
  CNAME_VALIDATOR.const_defined?(possible_cpath, false)
  possible_cpath
end