From: Gregory Brown Date: 2007-01-22T04:54:13+09:00 Subject: Re: inspect...and modify a proc object? On 1/21/07, kelly wrote: > myproc.methods returns the methods of the proc object itself. The proc > object, I guess, is a container for the original block. I'm interested > in the contents of the original block. > > Any suggestions for exposing details about the original block? this seems just plain evil, so please think about why you'd ever do it, and also, look for better solutions! :) seltzer:~ sandal$ irb >> class Proc >> def eval_with_binding(string) >> eval string, binding >> end >> end => nil >> b = 20 => 20 >> a = lambda { |x| x + b } => # >> a.eval_with_binding("local_variables") => ["_", "__", "b", "a"] >> class B >> def local_vars_for_proc(p) >> p.eval_with_binding("local_variables") >> end >> end => nil >> c = B.new => # >> c.local_vars_for_proc(a) => ["_", "__", "b", "a", "c"]