Christopher D. wrote in post #1004068:
expect to resolve as if X was referenced within X::Foo, including
climbing up the chain, and to return the top-level X.
That’s a pain, I have in the past used modules to limit access to only a
predefined set of things:
module Foo; end
module Bar; end
dirty = “Foo”
m = Safe.const_get(dirty) # ok
dirty = “Object”
m = Safe.const_get(dirty) # I wanted this to fail
I guess you need to build an explicit Hash.
Yes, in the actual code X is being referenced from within Foo but is
not fully qualified.
Is it partially qualified, or a completely bare ‘X’?
Partially qualified is easy to reproduce:
module X; module Foo; Foo::X; end; end
NameError: uninitialized constant X::Foo::X
Note there is a subtle difference with the following:
module X::Foo; Foo::X; end
NameError: uninitialized constant X::Foo::Foo
I don’t think that’s the issue here, but I was once caught out by the
module A; module B; …; end; end
module A::B; …; end