From: Joel VanderWerf Date: 2007-02-26T04:38:38+09:00 Subject: Re: Blocks in class_eval Kyle Mitchell wrote: > the following works: > > ///// BEGIN funcmeta.rb ///// > def func_meta(&b) > class_eval { > @@proc = b #guilt begins here > def test > @@proc.call > end > } > end > > class Test > func_meta { puts("test") } > end > > t = Test.new > t.test > ///// END funcmeta.rb ///// > > any clean way to do this without resorting to a class variable? > > thanks in advance, you darned helpful people! > > ~Kyle def func_meta(&b) class_eval { define_method :test, &b } end class Test func_meta { puts("test") } end t = Test.new t.test -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407