I know that I can capture the moment of a method definition by using set_trace_func
.
set_trace_func ->event, file, line, method, binding, klass{
if event == "c-call" and method == :method_added
# The moment of method definition
end
}
- Is it possible to capture the name of the method being defined at such moment? I know that the class can be captured by
eval("self", binding)
. What code can I put inside the block shown above to capture the method name? - Is it further possible to get the format of the arguments for the method being defined (the required arguments, the rest of the arguments, and their names as is in the source)?