Reputation: 7855
I'm just getting started with meta-programming, and am wondering if there's a way to view method chains similar to class ancestral chains?
For example, imagine I have a method that looks like this:
def method_a
method_b
end
method_b
# ..
end
If I call method_a like so:
method_a
It should run method_b
Is there a way from within method_b to determine that method_a was responsible for calling it?
Upvotes: 0
Views: 68
Reputation: 3356
If you are using ruby debugger then where
command will spit out the call stack for you current code execution
Upvotes: 0
Reputation: 19485
Take a look at Kernel#caller
, which should give you the information you want.
Upvotes: 3