NAME
Class::MakeMethods::Standard - Guide to subclasses
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 Standard::* namespace, and the method types each one provides.
The Standard subclasses provide a parameterized set of method-generation implementations.
Subroutines are generated as closures bound to a hash containing the method name and (optionally) additional parameters.
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.
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.
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.
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.
scalar: get and set scalar values for each instance or class
Composite::Universal (Any)
patch: add pre and post operations to an existing subroutine
hook: create a subroutine intended to have operations added to it
SEE ALSO
See Class::MakeMethods for an overview of the method-generation framework this is based on.
See Class::MakeMethods::Guide for a getting-started guide, annotated examples of usage, and a listing of the method generation classes included in this distribution.
See Class::MakeMethods::ReadMe for distribution, installation, version and support information.