I have a module called Plants which has a const_missing method and a class called Sunflower inside it. When I call an undefined constant, the const_missing method inside the module is not called. Instead the const_missing inside the Object class is called. Is there a way to get the const_missing inside the module to be triggered?
module Plants
def self.const_missing(name)
puts name
end
class Sunflower
def some_method
Grass
end
end
end
obj = Plants::Sunflower.new
obj.some_method
Thanks in advance! 🙂
1 Answer