wrap_method¶ ↑
Useful for callbacks, benchmarking, profiling, code graphs.
Example¶ ↑
require 'rubygems' require 'wrap_method' class Module def make_cool(method_name) wrap_method(method_name) do |org_method, args, block| puts 'Pssst!' result = org_method.call(*args, &block) puts ' Sexy girl!!!' result end end end class Person def greet puts ' Hey there..' end end Person.make_cool :greet Person.new.greet
Output¶ ↑
Pssst! Hey there.. Sexy girl!!!
Copyright¶ ↑
I am not the author, am just providing people with the gem. original code and author can be found here: