The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Class::Wrap - Proxy an entire class's methods.

SYNOPSIS

    use Some::Class;
    use Class::Wrap;

    wrap { print "We called the ", shift, " method!\n" } Some::Class;

DESCRIPTION

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.

EXPORTS

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.

AUTHOR

Simon Cozens, simon@cpan.org

LICENSE

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