1MakeMethods::Standard::UUsneirveCrosnatlr(i3b)uted PerlMDaokceuMmeetnhtoadtsi:o:nStandard::Universal(3)
2
3
4

NAME

6       Class::MakeMethods::Standard::Universal - Generic Methods
7

SYNOPSIS

9         package MyObject;
10         use Class::MakeMethods::Standard::Universal (
11           no_op => 'this',
12           abstract => 'that',
13           delegate => { name=>'play_music', target=>'instrument', method=>'play' },
14         );
15

DESCRIPTION

17       The Standard::Universal suclass of MakeMethods provides a [INCOMPLETE].
18
19   Calling Conventions
20       When you "use" this package, the method names you provide as arguments
21       cause subroutines to be generated and installed in your module.
22
23       See "Calling Conventions" in Class::MakeMethods::Standard for more
24       information.
25
26   Declaration Syntax
27       To declare methods, pass in pairs of a method-type name followed by one
28       or more method names.
29
30       Valid method-type names for this package are listed in "METHOD
31       GENERATOR TYPES".
32
33       See "Declaration Syntax" in Class::MakeMethods::Standard and "Parameter
34       Syntax" in Class::MakeMethods::Standard for more information.
35

METHOD GENERATOR TYPES

37   no_op - Placeholder
38       For each method name passed, returns a subroutine with the following
39       characteristics:
40
41       ·   Does nothing.
42
43       You might want to create and use such methods to provide hooks for
44       subclass activity.
45
46       Sample declaration and usage:
47
48         package MyObject;
49         use Class::MakeMethods::Standard::Universal (
50           no_op => 'whatever',
51         );
52         ...
53
54         # Doesn't do anything
55         MyObject->whatever();
56
57   abstract - Placeholder
58       For each method name passed, returns a subroutine with the following
59       characteristics:
60
61       ·   Fails with an error message.
62
63       This is intended to support the use of abstract methods, that must be
64       overidden in a useful subclass.
65
66       If each subclass is expected to provide an implementation of a given
67       method, using this abstract method will replace the generic error
68       message below with the clearer, more explicit error message that
69       follows it:
70
71         Can't locate object method "foo" via package "My::Subclass"
72         The "foo" method is abstract and can not be called on My::Subclass
73
74       However, note that the existence of this method will be detected by
75       UNIVERSAL::can(), so it is not suitable for use in optional interfaces,
76       for which you may wish to be able to detect whether the method is
77       supported or not.
78
79       Sample declaration and usage:
80
81         package MyObject;
82         use Class::MakeMethods::Standard::Universal (
83           abstract => 'whatever',
84         );
85         ...
86
87         package MySubclass;
88         sub whatever { ... }
89
90         # Failure
91         MyObject->whatever();
92
93         # Success
94         MySubclass->whatever();
95
96   call_methods - Call methods by name
97       For each method name passed, returns a subroutine with the following
98       characteristics:
99
100       ·   Accepts a hash of key-value pairs, or a reference to hash of such
101           pairs. For each pair, the key is interpreted as the name of a
102           method to call, and the value is the argument to be passed to that
103           method.
104
105       Sample declaration and usage:
106
107         package MyObject;
108         use Class::MakeMethods::Standard::Universal (
109           call_methods => 'init',
110         );
111         ...
112
113         my $object = MyObject->new()
114         $object->init( foo => 'Foozle', bar => 'Barbados' );
115
116         # Equivalent to:
117         $object->foo('Foozle');
118         $object->bar('Barbados');
119
120   join_methods - Concatenate results of other methods
121       For each method name passed, returns a subroutine with the following
122       characteristics:
123
124       ·   Has a list of other methods names as an arrayref in the 'methods'
125           parameter. Required.
126
127       ·   When called, calls each of the named method on itself, in order,
128           and returns the concatenation of their results.
129
130       ·   If a 'join' parameter is provided it is included between each
131           method result.
132
133       ·   If the 'skip_blanks' parameter is omitted, or is provided with a
134           true value, removes all undefined or empty-string values from the
135           results.
136
137   alias - Call another method
138       For each method name passed, returns a subroutine with the following
139       characteristics:
140
141       ·   Calls another method on the same callee.
142
143       You might create such a method to extend or adapt your class'
144       interface.
145
146       Sample declaration and usage:
147
148         package MyObject;
149         use Class::MakeMethods::Standard::Universal (
150           alias => { name=>'click_here', target=>'complex_machinery' }
151         );
152         sub complex_machinery { ... }
153         ...
154
155         $myobj->click_here(...); # calls $myobj->complex_machinery(...)
156
157   delegate - Use another object to provide method
158       For each method name passed, returns a subroutine with the following
159       characteristics:
160
161       ·   Calls a method on self to retrieve another object, and then calls a
162           method on that object and returns its value.
163
164       You might want to create and use such methods to faciliate composition
165       of objects from smaller objects.
166
167       Sample declaration and usage:
168
169         package MyObject;
170         use Class::MakeMethods::Standard::Universal (
171           'Standard::Hash:object' => { name=>'instrument' },
172           delegate => { name=>'play_music', target=>'instrument', method=>'play' }
173         );
174         ...
175
176         my $object = MyObject->new();
177         $object->instrument( MyInstrument->new );
178         $object->play_music;
179

SEE ALSO

181       See Class::MakeMethods for general information about this distribution.
182
183       See Class::MakeMethods::Standard for more about this family of
184       subclasses.
185
186
187
188perl v5.30.1                      2020-01-29MakeMethods::Standard::Universal(3)
Impressum