MethodCalledHook
Give any class a method called method_called and anytime a method gets called, the method called method_called gets called (heh) with two arguments: a symbol of the method that was called and a binding object of the scope it was called from.
Installation
Add this line to your application's Gemfile:
gem 'method_called_hook'
And then execute:
$ bundle
Or install it yourself as:
$ gem install method_called_hook
Usage
class MyClass
def self.method_called method_id, scope
scope.eval 'do_something' if method_id == :some_method
end
end
I used this just for its cool factor in my Tamagotchi toy project, but maybe you can find a more useful job for it.
Contributing
- Fork it ( https://github.com/habibalamin-gems/method\_called\_hook/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request