Skip to content
Create a gist now

Instantly share code, notes, and snippets.

# Totally untested.
module MethodLogging
def self.included(base)
base.methods.each do |m|
alias_method :"old_#{m}", m
define_method(m) do |args|
puts "Called #{m}(#{args.map{|a|a.inspect}.join(', ')})"
return_value = send("old_#{m}", *args)
puts "# => #{return_value.inspect}"
return_value
end
end
end
end
class Foo
def bar
# ...
end
include MethodLogging
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.