Q:

Given the binding, determine what a rails method returns? 

I want to do some processing for every method that runs inside my rails code, for that I require some information about the method during run-time.  I am using set_trace_func to do this.  Inside set_trace_func we receive binding:
set_trace_func proc { |event, file, line, id, binding, classname|
  printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}

How can I determine from this binding what the function will return?  I know how to access variables, parameters and the like but can't figure out how to get the return value, also is there a better tool for doing this? 

A:

set_trace_func was superseded by TracePoint which is capable of inspecting a method's return_value:
def foo
  2 * 3
end

TracePoint.trace(:return) do |tp|
  puts "`#{tp.method_id}' returned #{tp.return_value.inspect}"
end

foo

Output:
`foo' returned 6

There's also :c_return to trace methods implemented in C and b_return for blocks.