From: Paul Brannan Date: 2004-10-07T02:41:26+09:00 Subject: Re: what is super? On Thu, Oct 07, 2004 at 01:02:51AM +0900, trans. (T. Onoma) wrote: > I ask b/c I was wondering if getting the binding of super is any way feasible. "super" is a method call that calls into the base class. What you want isn't to get the "binding of super" (which is really meaningless), but the binding for the block that is created when you call a method. There isn't any good way to do this, but you can hack it with set_trace_func: require 'thread' def call_and_get_binding(obj, method, *args, &block) critical = Thread.critical Thread.critical = true begin binding = nil set_trace_func proc { |*x| if x[0] == "call" then set_trace_func nil binding = x[4] end } result = obj.__send__(method, *args, &block) return binding, result ensure Thread.critical = critical end end def foo x = 1 end binding, result = call_and_get_binding(self, :foo) p eval("x", binding) #=> 1 Now why you'd want to do this is beyond me, but have fun... Paul