NAME
Class::MakeMethods::Composite - Make extensible compound methods
SYNOPSIS
package MyObject;
use Class::MakeMethods::Composite::Hash (
new => 'new',
scalar => [ 'foo', 'bar' ],
array => 'my_list',
hash => 'my_index',
);
DESCRIPTION
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.
Calling Conventions
When you use
this package, the method names you provide as arguments cause subroutines to be generated and installed in your module.
See "Calling Conventions" in Class::MakeMethods::Standard for more information.
Declaration Syntax
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.
About Composite Methods
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;
}
],
}
],
);
SUBCLASS CATALOG
Composite::Hash (Instances)
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
Composite::Array (Instances)
Methods for manipulating positional values in arrays. See Class::MakeMethods::Composite::Array 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
Composite::Global (Global)
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
Composite::Inheritable (Any)
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
Composite::Universal (Any)
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 ALSO
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.