It is not the private method of Object
that is called but the module method in Kernel
. You can check which method is called with set_trace_func
as described in the answer to a similar question:
irb(main):001:1> set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname if id.to_s == 'method_missing' }
=> #<Proc:0x0423d278@(irb):1>
irb(main):002:0> Object.method_missing :test
c-call (irb):4 method_missing Kernel
c-return (irb):4 method_missing Kernel
NoMethodError: undefined method `test' for Object:Class
from (irb):4
from :0
As some commenters pointed out in MRIs newer than 1.8.7 this behaviour has changed: method_missing
has been removed from Kernel
and the private instance method from Object
was moved to BasicObject
which is the new superclass.