From: Simon Strandgaard Date: 2003-11-18T07:47:17+09:00 Subject: Re: Yet Another Rite Thought: method combination On Mon, 17 Nov 2003 07:22:01 +0000, gabriele renzi wrote: > I just looked at matz' slides and I don't have a clear understanding > of ho9w this is suposed to work. > > Possibly this has been explained verbosely, But I can't get it from > the slide. > > So, this is the example: > > class Foo > def foo(*args) #1 > p 'foo' > end > def foo:pre (*args ) #2 > p 'pre' > end > end How about something like ? This is only a partial example.. I have no clue how to do it with proc's. But there should be a convertion from yield-block to proc. server> ruby a.rb before #test 42 after #test server> expand -t2 a.rb class Object def self.def_pre(*args) args.each{|symbol| begin meth = instance_method(symbol) rescue => e $stderr.puts "ERROR: symbol2method failure, " + e.inspect next end name = symbol.id2name org = "_defpre_"+name arguments = (meth.arity != 0) ? "(*a,&b)" : "(&b)" module_eval < -- Simon Strandgaard