0.0
No release in over 3 years
It takes an existing Ruby object and creates a new one, that accepts all method calls and passes them to the provided block, which can pass them further to the original object.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Intercepts All Method Calls to a Ruby Object

DevOps By Rultor.com We recommend RubyMine

rake PDD status Gem Version Test Coverage Yard Docs Hits-of-Code License

It decorates an existing Ruby object and intercepts all calls to all its methods:

require 'intercepted'
i = intercepted(42) do |e, m, args, r|
  if e == :after
    puts "#{m}(#{args.join(', ')}) -> #{r}"
  end
end
puts i + 4

Prints:

+(4) -> 46

The value of e may either be :after or :before. The value of m is the name of the method called (a symbol). The list of arguments passed are in the args. The result of method execution is in the r (it's nil when e is :before).

That's it.

How to contribute

Read these guidelines. Make sure your build is green before you contribute your pull request. You will need to have Ruby 3.0+ and Bundler installed. Then run:

bundle update
bundle exec rake

If it's clean and you don't see any error messages, submit your pull request.