Skip to content

Instantly share code, notes, and snippets.

@mrjabba
Created January 24, 2013 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrjabba/4628080 to your computer and use it in GitHub Desktop.
Save mrjabba/4628080 to your computer and use it in GitHub Desktop.
Ruby kernel#caller
Kernel has a great method you can call. "caller".
Returns an array of the stack that called you.
So if you want to just see your immediate caller,
you can do puts "who called me caller=#{caller.first}"
and it will print the immediate caller.
If your method is being called from multiple clients this seems useful in debugging..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment