1MakeMethods::Composite(U3s)er Contributed Perl DocumentatMiaokneMethods::Composite(3)
2
3
4

NAME

6       Class::MakeMethods::Composite - Make extensible compound methods
7

SYNOPSIS

9         package MyObject;
10         use Class::MakeMethods::Composite::Hash (
11           new => 'new',
12           scalar => [ 'foo', 'bar' ],
13           array => 'my_list',
14           hash => 'my_index',
15         );
16

DESCRIPTION

18       This document describes the various subclasses of Class::MakeMethods
19       included under the Composite::* namespace, and the method types each
20       one provides.
21
22       The Composite subclasses provide a parameterized set of method-genera‐
23       tion implementations.
24
25       Subroutines are generated as closures bound to a hash containing the
26       method name and additional parameters, including the arrays of subrou‐
27       tine references that will provide the method's functionality.
28
29       Calling Conventions
30
31       When you "use" this package, the method names you provide as arguments
32       cause subroutines to be generated and installed in your module.
33
34       See "Calling Conventions" in Class::MakeMethods::Standard for more
35       information.
36
37       Declaration Syntax
38
39       To declare methods, pass in pairs of a method-type name followed by one
40       or more method names.
41
42       Valid method-type names for this package are listed in "METHOD GENERA‐
43       TOR TYPES".
44
45       See "Declaration Syntax" in Class::MakeMethods::Standard and "Parameter
46       Syntax" in Class::MakeMethods::Standard for more information.
47
48       About Composite Methods
49
50       The methods generated by Class::MakeMethods::Composite are assembled
51       from groups of "fragment" subroutines, each of which provides some
52       aspect of the method's behavior.
53
54       You can add pre- and post- operations to any composite method.
55
56         package MyObject;
57         use Class::MakeMethods::Composite::Hash (
58           new => 'new',
59           scalar => [
60             'foo' => {
61               'pre_rules' => [
62                 sub {
63                   # Don't automatically convert list to array-ref
64                   croak "Too many arguments" if ( scalar @_ > 2 );
65                 }
66               ],
67               'post_rules' => [
68                 sub {
69                   # Don't let anyone see my credit card number!
70                   ${(pop)->{result}} =~ s/\d{13,16}/****/g;
71                 }
72               ],
73             }
74           ],
75         );
76

SEE ALSO

78       See Class::MakeMethods for general information about this distribution.
79
80       For distribution, installation, support, copyright and license informa‐
81       tion, see Class::MakeMethods::Docs::ReadMe.
82
83
84
85perl v5.8.8                       2004-09-06         MakeMethods::Composite(3)
Impressum