From: Massimiliano Mirra Date: 2001-11-25T22:46:39+09:00 Subject: [ruby-talk:26447] Re: dynamically redefining methods On Sun, Nov 25, 2001 at 12:38:11AM +0900, Jakub Travnik wrote: > try this: > module Loggable > def self.append_features(klass) > klass.instance_methods.each do |method| > klass.class_eval " alias ___#{method} #{method};"+ > " def #{method}(*params,&block);"+ > " ___#{method}(*params,&block);"+ > " puts 'call to #{method} logged';"+ > " end;" > end > end > end I wasn't aware of class_eval. It works perfectly, thanks! BTW, it also corrects an extra mistake in my code: I called ``super'' in the redefined method, but there isn't necessarily a superclass's method to call (neither there was in this case). Massimiliano