From: gabriele renzi Date: 2004-07-17T02:42:16+09:00 Subject: Re: Altering method lookup il Sat, 17 Jul 2004 02:23:04 +0900, Claus Spitzer ha scritto:: >I'm working on a project based on a Smalltalk paper, and a part of it >is to attempt to emulate changes in method lookup in Ruby as done in >Smalltalk. Namely, the paper mentions an alteration of the >no_such_method method in Smalltalk to have it do something before and >after each method execution. In Ruby, I have come as far as doing was'nt it doesNotUnderstand: ? > #/usr/bin/env ruby > > class Foo > def bar( baz, qux ) > print baz << " is quite a " << qux << "\n" > end > > def method_missing( aSymbol , *args ) > print "before\n" > send( :bar, *args ) probably bar *args would be enough.. Anyway remember to even handle given blocks >Again, after some thinking it does what it is supposed to do (since >method bar is defined, method_missing never gets called). But it is >not what I intend it to do (eventually). define your own class and delete *all* the methods except __send__ and maybe __id__. Then inherit from that. see: http://onestepback.org/index.cgi/Tech/Ruby/BlankSlate.rdoc also, this may be interesting to you IIUC: http://www.thekode.net/ruby/techniques/CapturingMethods.html