From: Eric Hodel Date: 2006-05-01T04:37:05+09:00 Subject: Re: from block to code (also: how to get the bindings of a block) On Apr 27, 2006, at 12:35 AM, chiaro scuro wrote: > Does anyone know how to convert a block to a string representation of > the code it contains? lib/r2chacks.rb in ZenHacks has this. > I would need that to inject some code within a block and evaluate the > resulting code. > > * I cannot simply append the code because I need the bindings of > the block. Bindings are not preserved. You'd need more magic than PT has to get these along with the block. > * I cannot explicitly return the bindings from the block because I am > working on a DSL. > * I cannot get the bindings after the call to the block because that > scope seems to have been cleaned after the call If you need the bindings from a proc you are probably trying to solve the wrong problem. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com