From: Meinrad Recheis Date: 2006-03-07T19:02:56+09:00 Subject: Re: best praxis to wrap methods? ------=_Part_2093_987305.1141725759967 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 3/7/06, Robert Klemme wrote: > > Meinrad Recheis wrote: > [snipped] > > Are you sure the code you presented actually works? IMHO your code will > fail if the method is defined in the same class (i.e. no "super" > possible). afaik calling super in a singleton method calls the overridden method of that object (of course i assert that the method to be wrapped exists). here is the working code snippet: def make_wrapper object, method object.instance_eval %{ def self.#{method}(*args, &block) puts "wrapped method #{method}" super end } end You could use Delegator for this. And, if the method you want to wrap > does not use a block define_method usually works quite well. ah, object.send( :define_method) is what i was looking for. thanks Kind regards > > robert > > > ------=_Part_2093_987305.1141725759967--