From: Thomas Fini Hansen Date: 2003-11-27T17:13:10+09:00 Subject: Re: Method wrapping On Thu, Nov 27, 2003 at 04:57:02PM +0900, T. Onoma wrote: > On Thursday 27 November 2003 08:22 am, Gavin Sinclair wrote: > > If you are redefining someone else's method in production, on your own > > head be it. You should be keeping to the same interface of the > > original, or else other code is likely to break. > > Exactly, and to do this requires understanding the interface. And more times > than not, if you are REDEFINING a method in this manner, your doing it in > totality. Juggling the hooks from before is not condusive. You'll end up > remove_method'ing them all anyway. OK, I'll add my take from the perspective of someone that's not played with Ruby that long. My first reaction to all this wrapper talk was 'WTF?', because it seemed very odd to me. But I think I've gotten the idea now. As I see it, wrapping is for those 'I want this too' situations, you don't really want to change the original method, but you need a bit of extra code. Debugging statements and logging of use springs to mind. The important part being that the extra code doesn't muck with the interface. If you really want to change the how the method works, you do as you do now, redefining the method itself, possibly renaming the old. I might be wrong though. -- Thomas beast@system-tnt.dk