Class::MakeMethods::Composite - Make extensible compound methods
package MyObject; use Class::MakeMethods::Composite::Hash ( new => 'new', scalar => [ 'foo', 'bar' ], array => 'my_list', hash => 'my_index', );
This document describes the various subclasses of Class::MakeMethods included under the Composite::* namespace, and the method types each one provides.
The Composite subclasses provide a parameterized set of method-generation implementations.
Subroutines are generated as closures bound to a hash containing the method name and additional parameters, including the arrays of subroutine references that will provide the method's functionality.
When you use this package, the method names you provide as arguments cause subroutines to be generated and installed in your module.
use
See "Calling Conventions" in Class::MakeMethods::Standard for more information.
To declare methods, pass in pairs of a method-type name followed by one or more method names.
Valid method-type names for this package are listed in "METHOD GENERATOR TYPES".
See "Declaration Syntax" in Class::MakeMethods::Standard and "Parameter Syntax" in Class::MakeMethods::Standard for more information.
The methods generated by Class::MakeMethods::Composite are assembled from groups of "fragment" subroutines, each of which provides some aspect of the method's behavior.
You can add pre- and post- operations to any composite method.
package MyObject; use Class::MakeMethods::Composite::Hash ( new => 'new', scalar => [ 'foo' => { 'pre_rules' => [ sub { # Don't automatically convert list to array-ref croak "Too many arguments" if ( scalar @_ > 2 ); } ], 'post_rules' => [ sub { # Don't let anyone see my credit card number! ${(pop)->{result}} =~ s/\d{13,16}/****/g; } ], } ], );
Methods for objects based on blessed hashes. See Class::MakeMethods::Composite::Hash for details.
new: create and copy instances
scalar: get and set scalar values in each instance
array: get and set values stored in an array refered to in each instance
hash: get and set values in a hash refered to in each instance
object: access an object refered to by each instance
Methods for manipulating positional values in arrays. See Class::MakeMethods::Composite::Array for details.
Methods for manipulating global data. See Class::MakeMethods::Composite::Global for details.
scalar: get and set global scalar
array: get and set values stored in a global array
hash: get and set values in a global hash
object: global access to an object ref
Methods for manipulating data which may be overridden per class or instance. Uses external data storage, so it works with objects of any underlying data type. See Class::MakeMethods::Composite::Inheritable for details.
scalar: get and set scalar values for each instance or class
hook: create a subroutine intended to have operations added to it
Methods for padding pre- and post-conditions to any class. See Class::MakeMethods::Composite::Universal for details.
patch: add pre and post operations to an existing subroutine
See Class::MakeMethods for an overview of the method-generation framework this is based on.
See Class::MakeMethods::ReadMe for distribution, installation, version and support information.
To install Class::MakeMethods, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::MakeMethods
CPAN shell
perl -MCPAN -e shell install Class::MakeMethods
For more information on module installation, please visit the detailed CPAN module installation guide.