1MakeMethods::Composite(U3s)er Contributed Perl DocumentatMiaokneMethods::Composite(3)
2
3
4
6 Class::MakeMethods::Composite - Make extensible compound methods
7
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
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-
23 generation implementations.
24
25 Subroutines are generated as closures bound to a hash containing the
26 method name and additional parameters, including the arrays of
27 subroutine references that will provide the method's functionality.
28
29 Calling Conventions
30 When you "use" this package, the method names you provide as arguments
31 cause subroutines to be generated and installed in your module.
32
33 See "Calling Conventions" in Class::MakeMethods::Standard for more
34 information.
35
36 Declaration Syntax
37 To declare methods, pass in pairs of a method-type name followed by one
38 or more method names.
39
40 Valid method-type names for this package are listed in "METHOD
41 GENERATOR TYPES".
42
43 See "Declaration Syntax" in Class::MakeMethods::Standard and "Parameter
44 Syntax" in Class::MakeMethods::Standard for more information.
45
46 About Composite Methods
47 The methods generated by Class::MakeMethods::Composite are assembled
48 from groups of "fragment" subroutines, each of which provides some
49 aspect of the method's behavior.
50
51 You can add pre- and post- operations to any composite method.
52
53 package MyObject;
54 use Class::MakeMethods::Composite::Hash (
55 new => 'new',
56 scalar => [
57 'foo' => {
58 'pre_rules' => [
59 sub {
60 # Don't automatically convert list to array-ref
61 croak "Too many arguments" if ( scalar @_ > 2 );
62 }
63 ],
64 'post_rules' => [
65 sub {
66 # Don't let anyone see my credit card number!
67 ${(pop)->{result}} =~ s/\d{13,16}/****/g;
68 }
69 ],
70 }
71 ],
72 );
73
75 See Class::MakeMethods for general information about this distribution.
76
77 For distribution, installation, support, copyright and license
78 information, see Class::MakeMethods::Docs::ReadMe.
79
80
81
82perl v5.38.0 2023-07-20 MakeMethods::Composite(3)