undef_method And The Inheritance Hierarchy
As the docs state, Ruby's undef_method
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
.
Last updated