From: nobu.nokada@... Date: 2003-12-06T09:11:15+09:00 Subject: Re: Using Modules as Decorators Hi, At Sat, 6 Dec 2003 04:12:03 +0900, Nathan Weston wrote: > > def decorate(obj, name) > > orig = orig_name(name) > > (class << obj; self; end).class_eval {alias_method(orig, name)} > > end > > Cool! I was wondering if there was a syntax for that, but I couldn't > figure it out so I just gave up and used eval. This construct sometimes appears here. > > def call_orig(obj, name, *args, &block) > > obj.__send__(orig_name(name), *args, &block) > > end > > What does __send__ do? And what's the block for? #send may be overridden, e.g. Socket, however, redefinition of __send__ is warned. $ ruby -e 'class Foo;def __send__;end;end' -e:1: warning: redefining `__send__' may cause serious problem When the original method yields, you have to pass the given block. -- Nobu Nakada