From: Dave Thomas <Dave / thomases.com> Subject: [ruby-talk:4892] Re: Re-binding a block Date: Tue, 12 Sep 2000 21:00:25 +0900 > matz / zetabits.com (Yukihiro Matsumoto) writes: > > > I don't think it's good idea to change instance_eval. How about this > > yet another trick (using yet undocumented unbound method). > > Unfortunately, sing instance methods doesn't quite work for me. > > What I'm truing to do is implement something similar to Lisp's advice > system, where you can hook a function, wrapping it in some additional > code that executes before and after the original function. What I'd > like to do is something like > > > class String > > hook :upcase do |_upcase, str| > res = _upcase(str) > res.tr '_', '~' > end > > end maybe i'm missing something but why not just use alias? class String alias _upcase upcase def upcase res = _upcase res.tr '_', '~' end end -- yashi