Skip to content

ktlacaelel/wrap_method

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!!!

I am not the author, am just providing people with the gem. original code and author can be found here:

www.erikveen.dds.nl/monitorfunctions/index.html

About

Method wrapper for ruby

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages