Created
May 22, 2012 15:36
-
-
Save manuelmorales/2769804 to your computer and use it in GitHub Desktop.
How to log every single call to a ruby instance
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
# From http://stackoverflow.com/questions/5513558/executing-code-for-every-method-call-in-a-ruby-module | |
class ChattyArray < Array | |
Array.instance_methods.each do |name| | |
m = instance_method(name) | |
define_method name do |*args, &block| | |
# puts caller.grep(/app_name/) if name == :certain_method | |
puts ([name] + args).inspect | |
m.bind(self).(*args, &block) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment