Created
October 18, 2012 02:48
-
-
Save BrianJoyce/3909599 to your computer and use it in GitHub Desktop.
set_trace_func mess around
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set_trace_func proc { |event, file, line, id, binding, classname| | |
| # puts "event: #{event} file #{file} line #{line} id #{id} binding #{binding.inspect} classname #{(classname.nil?) ? classname : classname.name}" | |
| # p binding | |
| # only interested in events of type 'call' (Ruby method calls) | |
| # see the docs for set_trace_func for other supported event types | |
| puts "#{classname} #{id} called" if id == 'method2' | |
| } | |
| class TodoList | |
| def method1 | |
| puts "in method a" | |
| end | |
| def method2 | |
| puts "in method b" | |
| end | |
| end | |
| b = TodoList.new | |
| c = TodoList.new | |
| b.method2 | |
| b.method1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment