++ed by:
1 non-PAUSE user
Author image Simon Cozens


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.

It should be smart enough to do the right thing with AUTOLOADs.


The module provides the wrap function:

    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


You may use and distribute this module under the terms of the Artistic or GPL licenses, at your choice.