1MakeMethods::Emulator::UMseetrhoCdoMnatkreirb(u3t)ed PerMlakDeoMceutmheondtsa:t:iEomnulator::MethodMaker(3)
2
3
4

NAME

6       Class::MakeMethods::Emulator::MethodMaker - Emulate Class::MethodMaker
7

SYNOPSIS

9         package MyObject;
10         use Class::MakeMethods::Emulator::MethodMaker(
11           new_with_init => 'new',
12           get_set       => [ qw / foo bar baz / ];
13         );
14
15         ... OR ...
16
17         package MyObject;
18         use Class::MakeMethods::Emulator::MethodMaker '-take_namespace';
19         use Class::MethodMaker (
20           new_with_init => 'new',
21           get_set       => [ qw / foo bar baz / ];
22         );
23

DESCRIPTION

25       This module provides emulation of Class::MethodMaker, using the
26       Class::MakeMethods framework.
27
28       Although originally based on Class::MethodMaker, the calling convention
29       for Class::MakeMethods differs in a variety of ways; most notably, the
30       names given to various types of methods have been changed, and the
31       format for specifying method attributes has been standardized. This
32       package uses the aliasing capability provided by Class::MakeMethods,
33       defining methods that modify the declaration arguments as necessary and
34       pass them off to various subclasses of Class::MakeMethods.
35

COMPATIBILITY

37       Full compatibility is maintained with version 1.03; some of the changes
38       in versions 1.04 through 1.10 are not yet included.
39
40       The test suite from Class::MethodMaker version 1.10 is included with
41       this package, in the t/emulator_class_methodmaker/ directory.  The
42       unsupported tests have names ending in ".todo".
43
44       The tests are unchanged from those in the Class::MethodMaker
45       distribution, except for the substitution of
46       "Class::MakeMethods::Emulator::MethodMaker" in the place of
47       "Class::MethodMaker".
48
49       In cases where earlier distributions of Class::MethodMaker contained a
50       different version of a test, it is also included. (Note that version
51       0.92's get_concat returned '' for empty values, but in version 0.96
52       this was changed to undef; this emulator follows the later behavior. To
53       avoid "use of undefined value" warnings from the 0.92 version of
54       get_concat.t, that test has been modified by appending a new flag after
55       the name, 'get_concat --noundef', which restores the earlier behavior.)
56

USAGE

58       There are several ways to call this emulation module:
59
60       •   Direct Access
61
62           Replace occurances in your code of "Class::MethodMaker" with
63           "Class::MakeMethods::Emulator::MethodMaker".
64
65       •   Install Emulation
66
67           If you "use Class::MakeMethods::Emulator::MethodMaker
68           '-take_namespace'", the Class::MethodMaker namespace will be
69           aliased to this package, and calls to the original package will be
70           transparently handled by this emulator.
71
72           To remove the emulation aliasing, call "use
73           Class::MakeMethods::Emulator::MethodMaker '-release_namespace'".
74
75           Note: This affects all subsequent uses of Class::MethodMaker in
76           your program, including those in other modules, and might cause
77           unexpected effects.
78
79       •   The -sugar Option
80
81           Passing '-sugar' as the first argument in a use or import call will
82           cause the 'methods' package to be declared as an alias to this one.
83
84           This allows you to write declarations in the following manner.
85
86             use Class::MakeMethods::Emulator::MethodMaker '-sugar';
87
88             make methods
89               get_set => [ qw / foo bar baz / ],
90               list    => [ qw / a b c / ];
91
92           Note: This feature is deprecated in Class::MethodMaker version 0.96
93           and later.
94

METHOD CATALOG

96       NOTE: The documentation below is derived from version 1.02 of
97       Class::MethodMaker. Class::MakeMethods::Emulator::MethodMaker provides
98       support for all of the features and examples shown below, with no
99       changes required.
100

CONSTRUCTOR METHODS

102   new
103       Equivalent to Class::MakeMethods 'Template::Hash:new --with_values'.
104
105   new_with_init
106       Equivalent to Class::MakeMethods 'Template::Hash:new --with_init'.
107
108   new_hash_init
109       Equivalent to Class::MakeMethods 'Template::Hash:new
110       --instance_with_methods'.
111
112   new_with_args
113       Equivalent to Class::MakeMethods 'Template::Hash:new --with_values'.
114
115   copy
116       Equivalent to Class::MakeMethods 'Template::Hash:new
117       --copy_with_values'.
118

SCALAR ACCESSORS

120   get_set
121       Basically equivalent to Class::MakeMethods 'Template::Hash:scalar',
122       except that various arguments are intercepted and converted into the
123       parallel Class::MakeMethods::Template interface declarations.
124
125   get_concat
126       Equivalent to Class::MakeMethods 'Template::Hash:string' with a special
127       interface declaration that provides the get_concat and clear behaviors.
128
129   counter
130       Equivalent to Class::MakeMethods 'Template::Hash:number --counter'.
131

OBJECT ACCESSORS

133       Basically equivalent to Class::MakeMethods 'Template::Hash:object' with
134       an declaration that provides the "delete_x" interface. Due to a
135       difference in expected argument syntax, the incoming arguments are
136       revised before being delegated to Template::Hash:object.
137
138   object_list
139       Basically equivalent to Class::MakeMethods 'Template::Hash:object_list'
140       with an declaration that provides the relevant helper methods. Due to a
141       difference in expected argument syntax, the incoming arguments are
142       revised before being delegated to Template::Hash:object_list.
143
144   forward
145       Basically equivalent to Class::MakeMethods
146       'Template::Universal:forward_methods'. Due to a difference in expected
147       argument syntax, the incoming arguments are revised before being
148       delegated to Template::Universal:forward_methods.
149
150         forward => [ comp => 'method1', comp2 => 'method2' ]
151
152       Define pass-through methods for certain fields.  The above defines that
153       method "method1" will be handled by component "comp", whilst method
154       "method2" will be handled by component "comp2".
155

REFERENCE ACCESSORS

157   list
158       Equivalent to Class::MakeMethods 'Template::Hash:array' with a custom
159       method naming interface.
160
161   hash
162       Equivalent to Class::MakeMethods 'Template::Hash:hash' with a custom
163       method naming interface.
164
165   tie_hash
166       Equivalent to Class::MakeMethods 'Template::Hash:tiedhash' with a
167       custom method naming interface.
168
169   hash_of_lists
170       Equivalent to Class::MakeMethods 'Template::Hash:hash_of_arrays', or if
171       the -static flag is present, to 'Template::Static:hash_of_arrays'.
172

STATIC ACCESSORS

174   static_get_set
175       Equivalent to Class::MakeMethods 'Template::Static:scalar' with a
176       custom method naming interface.
177
178   static_list
179       Equivalent to Class::MakeMethods 'Template::Static:array' with a custom
180       method naming interface.
181
182   static_hash
183       Equivalent to Class::MakeMethods 'Template::Static:hash' with a custom
184       method naming interface.
185

GROUPED ACCESSORS

187   boolean
188       Equivalent to Class::MakeMethods 'Template::Static:bits' with a custom
189       method naming interface.
190
191   grouped_fields
192       Creates get/set methods like get_set but also defines a method which
193       returns a list of the slots in the group.
194
195         use Class::MakeMethods::Emulator::MethodMaker
196           grouped_fields => [
197             some_group => [ qw / field1 field2 field3 / ],
198           ];
199
200       Its argument list is parsed as a hash of group-name => field-list
201       pairs. Get-set methods are defined for all the fields and a method with
202       the name of the group is defined which returns the list of fields in
203       the group.
204
205   struct
206       Equivalent to Class::MakeMethods 'Template::Hash::struct'.
207
208       Note: This feature is included but not documented in Class::MethodMaker
209       version 1.
210

INDEXED ACCESSORS

212   listed_attrib
213       Equivalent to Class::MakeMethods 'Template::Flyweight:boolean_index'
214       with a custom method naming interface.
215
216   key_attrib
217       Equivalent to Class::MakeMethods 'Template::Hash:string_index'.
218
219   key_with_create
220       Equivalent to Class::MakeMethods 'Template::Hash:string_index
221       --find_or_new'.
222

CODE ACCESSORS

224   code
225       Equivalent to Class::MakeMethods 'Template::Hash:code'.
226
227   method
228       Equivalent to Class::MakeMethods 'Template::Hash:code --method'.
229
230   abstract
231       Equivalent to Class::MakeMethods 'Template::Universal:croak
232       --abstract'.
233

ARRAY CONSTRUCTOR AND ACCESSORS

235   builtin_class (EXPERIMENTAL)
236       Equivalent to Class::MakeMethods 'Template::StructBuiltin:builtin_isa'
237       with a modified argument order.
238

CONVERSION

240       If you wish to convert your code from use of the Class::MethodMaker
241       emulator to direct use of Class::MakeMethods, you will need to adjust
242       the arguments specified in your "use" or "make" calls.
243
244       Often this is simply a matter of replacing the names of aliased method-
245       types listed below with the new equivalents.
246
247       For example, suppose that you code contained the following declaration:
248
249         use Class::MethodMaker (
250           counter => [ 'foo' ]
251         );
252
253       Consulting the listings below you can find that "counter" is an alias
254       for "Hash:number --counter" and you could thus revise your declaration
255       to read:
256
257         use Class::MakeMethods (
258           'Hash:number --counter' => [ 'foo' ]
259         );
260
261       However, note that those methods marked "(with custom interface)" below
262       have a different default naming convention for helper methods in
263       Class::MakeMethods, and you will need to either supply a similar
264       interface or alter your module's calling interface.
265
266       Also note that the "forward", "object", and "object_list" method types,
267       marked "(with modified arguments)" below, require their arguments to be
268       specified differently.
269
270       See Class::MakeMethods::Template::Generic for more information about
271       the default interfaces of these method types.
272
273   Hash methods
274       The following equivalencies are declared for old meta-method names that
275       are now handled by the Hash implementation:
276
277         new              'Template::Hash:new --with_values'
278         new_with_init    'Template::Hash:new --with_init'
279         new_hash_init    'Template::Hash:new --instance_with_methods'
280         copy             'Template::Hash:copy'
281         get_set          'Template::Hash:scalar' (with custom interfaces)
282         counter          'Template::Hash:number --counter'
283         get_concat       'Template::Hash:string --get_concat' (with custom interface)
284         boolean          'Template::Hash:bits' (with custom interface)
285         list             'Template::Hash:array' (with custom interface)
286         struct           'Template::Hash:struct'
287         hash             'Template::Hash:hash' (with custom interface)
288         tie_hash         'Template::Hash:tiedhash' (with custom interface)
289         hash_of_lists    'Template::Hash:hash_of_arrays'
290         code             'Template::Hash:code'
291         method           'Template::Hash:code --method'
292         object           'Template::Hash:object' (with custom interface and modified arguments)
293         object_list      'Template::Hash:array_of_objects' (with custom interface and modified arguments)
294         key_attrib       'Template::Hash:string_index'
295         key_with_create  'Template::Hash:string_index --find_or_new'
296
297   Static methods
298       The following equivalencies are declared for old meta-method names that
299       are now handled by the Static implementation:
300
301         static_get_set   'Template::Static:scalar' (with custom interface)
302         static_hash      'Template::Static:hash' (with custom interface)
303
304   Flyweight method
305       The following equivalency is declared for the one old meta-method name
306       that us now handled by the Flyweight implementation:
307
308         listed_attrib   'Template::Flyweight:boolean_index'
309
310   Struct methods
311       The following equivalencies are declared for old meta-method names that
312       are now handled by the Struct implementation:
313
314         builtin_class   'Template::Struct:builtin_isa'
315
316   Universal methods
317       The following equivalencies are declared for old meta-method names that
318       are now handled by the Universal implementation:
319
320         abstract         'Template::Universal:croak --abstract'
321         forward          'Template::Universal:forward_methods' (with modified arguments)
322

EXTENDING

324       In order to enable third-party subclasses of MethodMaker to run under
325       this emulator, several aliases or stub replacements are provided for
326       internal Class::MethodMaker methods which have been eliminated or
327       renamed.
328
329       •   install_methods - now simply return the desired methods
330
331       •   find_target_class - now passed in as the target_class attribute
332
333       •   ima_method_maker - no longer supported; use target_class instead
334

BUGS

336       This module aims to provide a 100% compatible drop-in replacement for
337       Class::MethodMaker; if you detect a difference when using this
338       emulation, please inform the author.
339

SEE ALSO

341       See Class::MakeMethods for general information about this distribution.
342
343       See Class::MakeMethods::Emulator for more about this family of
344       subclasses.
345
346       See Class::MethodMaker for more information about the original module.
347
348       A good introduction to Class::MethodMaker is provided by pages 222-234
349       of Object Oriented Perl, by Damian Conway (Manning, 1999).
350
351         http://www.browsebooks.com/Conway/
352
353
354
355perl v5.34.0                      2022-01-M2a1keMethods::Emulator::MethodMaker(3)
Impressum