Created
September 14, 2011 21:55
-
-
Save FestivalBobcats/1217912 to your computer and use it in GitHub Desktop.
Inspect every method as it's called
This file contains 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
module Breadcrumbs | |
def self.included(mod) | |
mod.extend ClassMethods | |
mod.class_variable_set :@@__defined_methods, [] | |
end | |
module ClassMethods | |
def method_added(m) | |
unless (meths = class_variable_get(:@@__defined_methods)).include?(m) | |
class_variable_set :@@__defined_methods, meths << m | |
meth = instance_method(m) | |
remove_method(m) | |
define_method m do | |
puts "\n--------> \e[34m#{ self.class }\e[36m##{ m }\e[0m\n\n" | |
meth.bind(self).call | |
end | |
end | |
end | |
end | |
end | |
Object.send(:include, Breadcrumbs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment