Skip to content

Instantly share code, notes, and snippets.

@BrianJoyce
Created October 18, 2012 02:48
Show Gist options
  • Save BrianJoyce/3909599 to your computer and use it in GitHub Desktop.
Save BrianJoyce/3909599 to your computer and use it in GitHub Desktop.
set_trace_func mess around
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