From: "Peña, Botp" Date: 2004-01-28T10:33:44+09:00 Subject: Re: nuby: determine method passed and determine the receiver that rec eived the method > > # keep this secret :P > > module MethodCalledMagic > > def method_added(id) > > @level ||= 0 > > return if @level == 1 > > @level += 1 > > alias_method "_real_#{id}", id > > module_eval <<-EOF > > def #{id}(*a,&b) > > puts "You called #{self.inspect}##{id}" > > _real_#{id}(*a,&b) > > end > > EOF > > @level -= 1 > > end > > > > def self.extend_object(obj) > > obj.send :define_method, :method_missing do |id,*a| > > puts "You called #{self.class}##{id}" > > super id > > end > > super > > end > > end > > Promise us you will never show this code to anyone who is > considering ruby. They will run away screaming halfway > through the first method. > I thought it was a simple request ( -that an object know what messages/methods was passed to it). Batsman solution provides rediversions using extend_object and method_added (wc looks kludgy imho). It works, but I hope there are more "cleaner" solutions to come. kind regards -botp