| Short description: |
Module to make selected methods of a class hookable |
| Category: |
Library/Development |
| Status: |
alpha |
| Created: |
2005-06-24 10:55:27 GMT |
| Last update: |
2005-06-24 10:55:27 GMT |
| Owner: |
Jan Krüger
(Projects of this owner) |
| Homepage: |
http://heapsort.de/circus/doc/classes/Hookable.html |
| Download: |
http://heapsort.de/va/jast%40heapsort.de--swordcoast-2004/circus--dev--0.1--patch-39/src/Hookable.rb?text
|
| License: |
GPL |
| Dependency: |
|
| Description: |
Hookable provides you with the ability to hook into methods. Mix Hookable into a class and you can designate methods that can be hooked into.
A hook is a Proc that gets passed the object the hooked method is bound to, and the list of arguments passed to the hooked method. This Proc can then do whatever it wants to do and call the original method in the process.
-----
Hookable::Wrapper manages a number of instance methods that can easily be wrapped around instance methods of another class (as can be done with Hookable::ClassMethods#add_hook).
There are class methods to add, remove, enable or disable one or all instance methods for one target class. You can, for example, wrap one method of a Wrapper subclass around a method in Foo and, at the same time, all methods of the same Wrapper subclass around the corresponding methods in Foo.
Your wrapper method will get exactly the same arguments as the wrapped method, plus a prepended Hookable::State argument.
|