From: ara.t.howard@... Date: 2006-12-11T02:08:24+09:00 Subject: Re: bending ruby space On Mon, 11 Dec 2006, Trans wrote: > in any case you all are partly right of course. but the neat part of > this --the real "bending" and the reason it uses two modules the way > it does.... > > module R; end > module U; include R; end > module R; extend U; end > > module R > def x; "x"; end > end > > module U > def x; "{" + super + "}"; end > end > > R.x #=> "{x}" > > the effect is *dynamic* AOP wrapping of R by U. it is dynamic b/c it is > possible to define the "aspect" U prior to any corresponding method in > R. (btw, 'if defined?(super)' is helpful in such cases). I used this > myself to cache specifically named methods that may, or may not, be in > a user-defined code snippet. > it is unfortuate however that, afaict, the same pattern can't be used > on a class --just a module. dynamically injectable 'super' - very useful. cheers. -a -- if you want others to be happy, practice compassion. if you want to be happy, practice compassion. -- the dalai lama