Intercepts All Method Calls to a Ruby Object
It decorates an existing Ruby object and intercepts all calls to all its methods:
require 'intercepted'
i = intercepted(42) do |o, name, *args, &block|
r = o.__send__(name, *args, &block)
puts "#{name}(#{args.join(', ')}) -> #{r}"
r
end
puts i + 4
Prints:
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.