Hi, if class A contains method “hello” and class B inherits from A, is
it possible to remove method “hello” in the definition of class B?
Maybe a workaround could be making “hello” method private in class B.
NOTE: I do know that I can override “hello” method (something as “def
hello; nil; end”) but I don’t want it.
Thanks for any suggestion.
On Fri, Mar 4, 2011 at 6:14 PM, Iñaki Baz C. [email protected]
wrote:
Hi, if class A contains method “hello” and class B inherits from A, is
it possible to remove method “hello” in the definition of class B?
Maybe a workaround could be making “hello” method private in class B.
NOTE: I do know that I can override “hello” method (something as “def
hello; nil; end”) but I don’t want it.
Are you looking to do this to make it use A#hello instead of B#hello ?
If
so, you might consider using super
. That aside, you can look at
Kernel#undef_method and Kernel#remove_method (the two have different
semantics).
http://ruby-doc.org/core/classes/Module.html#M000446
2011/3/4 Adam P. [email protected]:
Are you looking to do this to make it use A#hello instead of B#hello ? If
so, you might consider using super
. That aside, you can look at
Kernel#undef_method and Kernel#remove_method (the two have different
semantics).
class Module - RDoc Documentation
Kernel#undef_method is exactly what I was looking for
Thanks a lot.