C
Chris Roos
Assuming the following snippet, I'd expect Foo::const_defined?Bar)
to be routed via Foo::const_missing. Instead it resolves to top-level
Bar. Can someone explain why please?
--code--
class Bar
end
module Foo
def self.const_missing(konst)
puts "missing konst #{konst}"
end
end
Foo::Bar
#=> missing konst Bar # Unsurprising behaviour
p Foo::const_defined?Bar)
false # Unsurprising behaviour
p Foo::const_getBar)
#=> Bar # Surprising behaviour
--/code--
Cheers,
Chris
to be routed via Foo::const_missing. Instead it resolves to top-level
Bar. Can someone explain why please?
--code--
class Bar
end
module Foo
def self.const_missing(konst)
puts "missing konst #{konst}"
end
end
Foo::Bar
#=> missing konst Bar # Unsurprising behaviour
p Foo::const_defined?Bar)
false # Unsurprising behaviour
p Foo::const_getBar)
#=> Bar # Surprising behaviour
--/code--
Cheers,
Chris