Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
log_method_call
def self.log_method_call(method_name)
original_method = instance_method(method_name)
define_method(method_name) do |*args, &block|
puts caller[3..5]
puts "-> #{self.inspect}##{method_name}(#{args.inspect})"
return_value = original_method.bind(self).call(*args, &block)
puts "<- #{self.inspect}##{method_name} #=> #{return_value.inspect}"
return_value
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.