Skip to content

Instantly share code, notes, and snippets.

@FestivalBobcats
Created September 14, 2011 21:55
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 FestivalBobcats/1217912 to your computer and use it in GitHub Desktop.
Save FestivalBobcats/1217912 to your computer and use it in GitHub Desktop.
Inspect every method as it's called
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