From: eden li Date: 2007-03-16T12:38:35+09:00 Subject: Re: When introspection doesn't... The power of Ruby :) Everything can be redefined or undefined, although there are a few warnings that Ruby will complain about: $ irb irb(main):001:0> class C; undef_method :__send__, :__id__; end (irb):1: warning: undefining `__send__' may cause serious problem (irb):1: warning: undefining `__id__' may cause serious problem You can also look at remove_method which will get rid of any methods defined in your class after you've defined them, but it won't touch anything in the super class. You might have to resort to C to write the "super introspector" since some of the internal data structures ruby uses aren't accessible from the language itself (or at least that seems to be the case from the cursory inspection I did on eval.c). For instance -- I couldn't find any way to get the receiving class from Method or UnboundMethod... they're locked up in struct METHOD somehow. The only hack I could come up with was to parse the output of to_s: class UnboundMethod def rclass to_s.scan(/: (\w+)[(#]/).flatten.map{|s|Object.const_get(s)}.first end end >> Array.instance_method(:[]).class => UnboundMethod >> Array.instance_method(:[]).rclass => Array On Mar 16, 3:13 am, Chad Lester wrote: > Also... it does kind of make wish there were some methods that one could > not override, just so you can poke in and see what's going on without > resorting to c programming. Or maybe this would be better done with a > special inspector object that knows how to inspect objects... I'll look > for one, and then maybe write one if I can't find anything.