Class::Wrap - Proxy an entire class's methods.
use Some::Class; use Class::Wrap; wrap { print "We called the ", shift, " method!\n" } Some::Class;
There are several modules on CPAN which claim to help with wrapping classes; this is not like any of them. It provides a single pre- wrapper on all of a class's defined methods; it works on a class instead of an object basis.
The scenario I had in mind was wanting to know which methods of a particular class were being used by a very complex program; Class::Wrap helped understand what was being used and when, in order to make a decision about whether or not to replace the class.
Class::Wrap
It should be smart enough to do the right thing with AUTOLOADs.
The module provides the wrap function:
wrap
wrap { coderef } "Package Name";
This will wrap all existing methods in the given class. The coderef is passed the name of the method called plus the parameters. This allows you to perform different actions based on the name of the method, so it's not a problem that only one wrapper fits the whole class.
Simon Cozens, simon@cpan.org
simon@cpan.org
You may use and distribute this module under the terms of the Artistic or GPL licenses, at your choice.
To install Class::Wrap, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Wrap
CPAN shell
perl -MCPAN -e shell install Class::Wrap
For more information on module installation, please visit the detailed CPAN module installation guide.