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

  1. Fork it ( https://github.com/habibalamin-gems/method\_called\_hook/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request