undef_method And The Inheritance Hierarchy
Last updated
Was this helpful?
Last updated
Was this helpful?
As the docs state, Ruby's
prevents the current class from responding to calls to the named method.
This means you can do some weird things to the inheritance hierarchy. I'll use the following code example to illustrate.
Everything works as expect. Now, I'll use undef_method
.
Not only have instances of Smartphone
been prevented from responding to ring
, but any subclasses of Smartphone
that call ring
will get tripped up when traversing the inheritance hierarchy in search of a definition of ring
.