1MakeMethods::Template::UGseenrerCiocn(t3r)ibuted Perl DoMcaukmeeMnettahtoidosn::Template::Generic(3)
2
3
4

NAME

6       Class::MakeMethods::Template::Generic - Templates for common
7       meta-method types
8

SYNOPSIS

10         package MyObject;
11         use Class::MakeMethods (
12           'Template::Hash:new'       => [ 'new' ],
13           'Template::Hash:scalar'    => [ 'foo' ]
14           'Template::Static:scalar'  => [ 'bar' ]
15         );
16
17         package main;
18
19         my $obj = MyObject->new( foo => "Foozle", bar => "Bozzle" );
20         print $obj->foo();
21         $obj->bar("Bamboozle");
22

DESCRIPTION

24       This package provides a variety of abstract interfaces for constructors
25       and accessor methods, which form a common foundation for meta-methods
26       provided by the Hash, Scalar, Flyweight, Static, PackageVar, and
27       ClassVar implementations.
28
29       Generally speaking, the Generic meta-methods define calling interfaces
30       and behaviors which are bound to differently scoped data by each of
31       those implementations.
32
33       (Note that those implementation classes are not subclasses of Generic;
34       instead they import various interfaces and code fragments from the
35       meta-method types defined here, by specifying '-import' values which
36       are processed by Class::MakeMethods's _metamethod_definition
37       mechanism.)
38
39   new Constructor
40       There are several types of hash-based object constructors to choose
41       from.
42
43       Each of these methods creates and returns a reference to a new blessed
44       instance. They differ in how their (optional) arguments are interpreted
45       to set initial values, and in how they operate when called as class or
46       instance methods.
47
48       Interfaces: The following interfaces are supported.
49
50       -with_values,
51           Provides the with_values behavior.
52
53       -with_init
54           Provides the with_init behavior.
55
56       -with_methods
57           Provides the with_methods behavior.
58
59       -new_and_init
60           Provides the with_init behavior for *, and the general purpose
61           method_init behavior as an init method.
62
63       -copy_with_values
64           Provides the copy behavior.
65
66       Behaviors: The following types of constructor methods are available.
67
68       with_values
69           Creates and blesses a new instance.
70
71           If arguments are passed they are included in the instance,
72           otherwise it will be empty.
73
74           Returns the new instance.
75
76           May be called as a class or instance method.
77
78       with_methods
79           Creates, blesses, and returns a new instance.
80
81           The arguments are treated as a hash of method-name/argument-value
82           pairs, with each such pair causing a call "$self->name($value)".
83
84       with_init
85           Creates and blesses a new instance, then calls a method named
86           "init", passing along any arguments that were initially given.
87
88           Returns the new instance.
89
90           The init() method should be defined in the class declaring these
91           methods.
92
93           May be called as a class or instance method.
94
95       and_then_init
96           Creates a new instance using method-name/argument-value pairs, like
97           "with_methods", but then calls a method named "init" before
98           returning the new object. The "init" method does not receive any
99           arguments.
100
101           The init() method should be defined in the class declaring these
102           methods.
103
104       instance_with_methods
105           If called as a class method, creates, blesses, and returns a new
106           instance. If called as an object method, operates on and returns
107           the existing instance.
108
109           Accepts name-value pair arguments, or a reference to hash of such
110           pairs, and calls the named method for each with the supplied value
111           as a single argument. (See the Universal method_init behavior for
112           more discussion of this pattern.)
113
114       copy_with values
115           Produce a copy of an instance. Can not be called as a class method.
116
117           The copy is a *shallow* copy; any references will be shared by the
118           instance upon which the method is called and the returned newborn.
119
120           If a list of key-value pairs is passed as arguments to the method,
121           they are added to the copy, overwriting any values with the same
122           key that may have been copied from the original.
123
124       copy_with_methods
125           Produce a copy of an instance. Can not be called as a class method.
126
127           The copy is a *shallow* copy; any references will be shared by the
128           instance upon which the method is called and the returned newborn.
129
130           Accepts name-value pair arguments, or a reference to hash of such
131           pairs, and calls the named method on the copy for each with the
132           supplied value as a single argument before the copy is returned.
133
134       copy_instance_with_values
135           If called as a class method, creates, blesses, and returns a new
136           instance. If called as an object method, produces and returns a
137           copy of an instance.
138
139           The copy is a *shallow* copy; any references will be shared by the
140           instance upon which the method is called and the returned newborn.
141
142           If a list of key-value pairs is passed as arguments to the method,
143           they are added to the copy, overwriting any values with the same
144           key that may have been copied from the original.
145
146       copy_instance_with_methods
147           If called as a class method, creates, blesses, and returns a new
148           instance. If called as an object method, produces and returns a
149           copy of an instance.
150
151           The copy is a *shallow* copy; any references will be shared by the
152           instance upon which the method is called and the returned newborn.
153
154           Accepts name-value pair arguments, or a reference to hash of such
155           pairs, and calls the named method on the copy for each with the
156           supplied value as a single argument before the copy is returned.
157
158       Parameters: The following parameters are supported:
159
160       init_method
161           The name of the method to call after creating a new instance.
162           Defaults to 'init'.
163
164   scalar Accessor
165       A generic scalar-value accessor meta-method which serves as an
166       abstraction for basic "get_set" methods and numerous related interfaces
167
168         use Class::MakeMethods -MakerClass => "...",
169               scalar => [ 'foo', 'bar' ];
170         ...
171         $self->foo( 'my new foo value' );
172         print $self->foo();
173
174       (Note that while you can use the scalar methods to store references to
175       various data structures, there are other meta-methods defined below
176       that may be more useful for managing references to arrays, hashes, and
177       objects.)
178
179       Interfaces: The following calling interfaces are available.
180
181       get_set (default)
182           Provides get_set method for *.
183
184           Example: Create method foo, which sets the value of 'foo' for this
185           instance if an argument is passed in, and then returns the value
186           whether or not it's been changed:
187
188             use Class::MakeMethods -MakerClass => "...",
189               scalar => [ 'foo' ];
190
191       get_protected_set
192           Provides an get_set accessor for * that croaks if a new value is
193           passed in from a package that is not a subclass of the declaring
194           one.
195
196       get_private_set
197           Provides an get_set accessor for * that croaks if a new value is
198           passed in from a package other than the declaring one.
199
200       read_only
201           Provides an accessor for * that does not modify its value. (Its
202           initial value would have to be set by some other means.)
203
204       eiffel
205           Provides get behavior as *, and set behavior as set_*.
206
207           Example: Create methods bar which returns the value of 'bar' for
208           this instance (takes no arguments), and set_bar, which sets the
209           value of 'bar' (no return):
210
211             use Class::MakeMethods -MakerClass => "...",
212               scalar => [ --eiffel => 'bar' ];
213
214       java
215           Provides get behavior as get*, and set behavior as set*.
216
217           Example: Create methods getBaz which returns the value of 'Baz' for
218           this instance (takes no arguments), and setBaz, which sets the
219           value for this instance (no return):
220
221             use Class::MakeMethods -MakerClass => "...",
222               scalar => [ --java => 'Baz' ];
223
224       init_and_get
225           Creates methods which cache their results in a hash key.
226
227           Provides the get_init behavior for *, and an delete behavior for
228           clear_*.  Specifies default value for init_method parameter of
229           init_*.
230
231       with_clear
232           Provides get_set behavior for *, and a clear_* method.
233
234       Behaviors: The following types of accessor methods are available.
235
236       get_set
237           If no argument is provided, returns the value of the current
238           instance. The value defaults to undef.
239
240           If an argument is provided, it is stored as the value of the
241           current instance (even if the argument is undef), and that value is
242           returned.
243
244           Also available as get_protected_set and get_private_set, which are
245           available for public read-only access, but have access control
246           limitations.
247
248       get Returns the value from the current instance.
249
250       set Sets the value for the current instance. If called with no
251           arguments, the value is set to undef. Does not return a value.
252
253       clear
254           Sets value to undef.
255
256       get_set_chain
257           Like get_set, but if called with an argument, returns the object it
258           was called on. This allows a series of mutators to be called as
259           follows:
260
261             package MyObject;
262             use Class::MakeMethods (
263               'Template::Hash:scalar --get_set_chain' => 'foo bar baz'
264             );
265             ...
266
267             my $obj = MyObject->new->foo('Foozle');
268             $obj->bar("none")->baz("Brazil");
269             print $obj->foo, $obj->bar, $obj->baz;
270
271       get_set_prev
272           Like get_set, but if called with an argument, returns the previous
273           value before it was changed to the new one.
274
275       get_init
276           If the value is currently undefined, calls the init_method. Returns
277           the value.
278
279       Parameters: The following parameters are supported:
280
281       init_method
282           The name of a method to be called to initialize this meta-method.
283
284           Only used by the get_init behavior.
285
286   string Accessor
287       A generic scalar-value accessor meta-method which serves as an
288       abstraction for basic "get_set" methods and numerous related interfaces
289
290         use Class::MakeMethods -MakerClass => "...",
291               string => [ 'foo', 'bar' ];
292         ...
293         $self->foo( 'my new foo value' );
294         print $self->foo();
295
296       This meta-method extends the scalar meta-method, and supports the same
297       interfaces and parameters.
298
299       However, it generally treats values as strings, and can not be used to
300       store references.
301
302       Interfaces: In addition to those provided by "scalar", the following
303       calling interfaces are available.
304
305       -get_concat
306           Provides the get_concat behavior for *, and a clear_* method.
307
308           Example:
309
310             use Class::MakeMethods
311               get_concat => { name => 'words', join => ", " };
312
313             $obj->words('foo');
314             $obj->words('bar');
315             $obj->words() eq 'foo, bar';
316
317       Behaviors: In addition to those provided by "scalar", the following
318       types of accessor methods are available.
319
320       concat
321           Concatenates the argument value with the existing value.
322
323       get_concat
324           Like get_set except sets do not clear out the original value, but
325           instead concatenate the new value to the existing one.
326
327       Parameters: In addition to those provided by "scalar", the following
328       parameters are supported.
329
330       join
331           If the join parameter is defined, each time the get_concat behavior
332           is invoked, it will glue its argument onto any existing value with
333           the join string as the separator. The join field is applied between
334           values, not prior to the first or after the last. Defaults to
335           undefined
336
337   string_index
338         string_index => [ qw / foo bar baz / ]
339
340       Creates string accessor methods, like string above, but also maintains
341       a static hash index in which each object is stored under the value of
342       the field when the slot is set.
343
344       This is a unique index, so only one object can have a given key.  If an
345       object has a slot set to a value which another object is already set to
346       the object currently set to that value has that slot set to undef and
347       the new object will be put into the hash under that value.
348
349       Objects with undefined values are not stored in the index.
350
351       Note that to free items from memory, you must clear these values!
352
353       Methods:
354
355       ·   The method find_x is defined which if called with any arguments
356           returns a list of the objects stored under those values in the
357           hash. Called with no arguments, it returns a reference to the hash.
358
359       Profiles:
360
361       ·   find_or_new
362
363             'string_index -find_or_new' => [ qw / foo bar baz / ]
364
365           Just like string_index except the find_x method is defined to call
366           the new method to create an object if there is no object already
367           stored under any of the keys you give as arguments.
368
369   number Accessor
370       A generic scalar-value accessor meta-method which serves as an
371       abstraction for basic "get_set" methods and numerous related interfaces
372
373         use Class::MakeMethods -MakerClass => "...",
374               string => [ 'foo', 'bar' ];
375         ...
376         $self->foo( 23 );
377         print $self->foo();
378
379       This meta-method extends the scalar meta-method, and supports the same
380       interfaces and parameters.
381
382       However, it generally treats values as numbers, and can not be used to
383       store strings or references.
384
385       Interfaces: In addition to those provided by "scalar", the following
386       calling interfaces are available.
387
388       -counter
389           Provides the numeric get_set behavior for *, and numeric *_incr and
390           *_reset methods.
391
392       Behaviors: In addition to those provided by "scalar", the following
393       types of accessor methods are available.
394
395       get_set
396           The get_set behavior is similar to the default scalar behavior
397           except that empty values are treated as zero.
398
399       increment
400           If no argument is provided, increments the hash_key value by 1.  If
401           an argument is provided, the value is incremented by that amount.
402           Returns the increased value.
403
404       clear
405           Sets the value to zero.
406
407   boolean Accessor
408       A generic scalar-value accessor meta-method which serves as an
409       abstraction for basic "get_set" methods and numerous related interfaces
410
411         use Class::MakeMethods -MakerClass => "...",
412               string => [ 'foo', 'bar' ];
413         ...
414         $self->foo( 1 );
415         print $self->foo();
416         $self->clear_foo;
417
418       This meta-method extends the scalar meta-method, and supports the same
419       interfaces and parameters. However, it generally treats values as true-
420       or-false flags, and can not be used to store strings, numbers, or
421       references.
422
423       Interfaces:
424
425       flag_set_clear (default)
426           Provides the get_set behavior for *, and set_* and clear_* methods
427           to set the value to true or false.
428
429       Behaviors: In addition to those provided by "scalar", the following
430       types of accessor methods are available.
431
432       get_set
433           The get_set behavior is similar to the get_set scalar behavior
434           except that empty or false values are treated as zero, and true
435           values are treated as zero.
436
437       set_true
438           Sets the value to one.
439
440       set_false
441           Sets the value to zero.  =back
442
443   bits Accessor
444       A generic accessor for bit-field values.
445
446       The difference between 'Template::Generic:bits' and
447       'Template::Generic:boolean' is that all flags created with this meta-
448       method are stored in a single vector for space efficiency.
449
450       Interfaces: The following calling interfaces are available.
451
452       default
453           Provides get_set behavior for *, a set_* method which sets the
454           value to true and a clear_* method which sets the value to false.
455
456           Also defines methods named bits, bit_fields, and bit_dump with the
457           behaviors below. These methods are shared across all of the boolean
458           meta-methods defined by a single class.
459
460       class_methods
461           .
462
463       Basic Behaviors: The following types of bit-level accessor methods are
464       available.
465
466       get_set
467           Returns the value of the named flag.  If called with an argument,
468           it first sets the named flag to the truth-value of the argument.
469
470       set_true
471           Sets the value to true.
472
473       set_false
474           Sets the value to false.
475
476       Group Methods: The following types of methods manipulate the overall
477       vector value.
478
479       bits
480           Returns the vector containing all of the bit fields (remember
481           however that a vector containing all 0 bits is still true).
482
483       bit_dump
484           Returns a hash of the flag-name/flag-value pairs.
485
486       bits_size
487           Returns the number of bits that can fit into the current vector.
488
489       bits_complement
490           Returns the twos-complement of the vector.
491
492       bit_pos_get
493           Takes a single argument and returns the value of the bit stored in
494           that position.
495
496       bit_pos_set
497           Takes two arguments and sets the bit stored in the position of the
498           first argument to the value of the second argument.
499
500       Class Methods: The following types of class methods are available.
501
502       bit_names
503           Returns a list of all the flags by name.
504
505   array Accessor
506       Creates accessor methods for manipulating arrays of values.
507
508       Interfaces: The following calling interfaces are available.
509
510       default
511           Provides get_set behavior for *, and verb_* methods for the non-get
512           behaviors below.
513
514       minimal
515           Provides get_set behavior for *, and *_verb methods for clear
516           behavior.
517
518       get_set_items
519           Provides the get_set_items for *.
520
521       x_verb
522           Provides get_push behavior for *, and *_verb methods for the non-
523           get behaviors below.
524
525       get_set_ref
526           Provides the get_set_ref for *.
527
528       get_set_ref_help
529           Provides the get_set_ref for *, and verb_* methods for the non-get
530           behaviors below.
531
532       Behaviors: The following types of accessor methods are available.
533
534       get_set_items
535           Called with no arguments returns a reference to the array stored in
536           the slot.
537
538           Called with one simple scalar argument it treats the argument as an
539           index and returns the value stored under that index.
540
541           Called with more than one argument, treats them as a series of
542           index/value pairs and adds them to the array.
543
544       get_push
545           If arguments are passed, these values are pushed on to the list; if
546           a single array ref is passed, its values are used as the arguments.
547
548           This method returns the list of values stored in the slot. In an
549           array context it returns them as an array and in a scalar context
550           as a reference to the array.
551
552       get_set_ref
553           If arguments are passed, these values are placed on the list,
554           replacing the current contents; if a single array ref is passed,
555           its values are used as the arguments.
556
557           This method returns the list of values stored in the slot. In an
558           array context it returns them as an array and in a scalar context
559           as a reference to the array.
560
561       get_set
562           If arguments are passed, these values are placed on the list,
563           replacing the current contents.
564
565           This method returns the list of values stored in the slot. In an
566           array context it returns them as an array and in a scalar context
567           as a reference to the array.
568
569       push
570           Append items to tail.
571
572       pop Remove an item from the tail.
573
574       shift
575           Remove an item from the front.
576
577       unshift
578           Prepend items to front.
579
580       splice
581           Remove or replace items.
582
583       clear
584           Remove all items.
585
586       count
587           Returns the number of item in the list.
588
589   hash Accessor
590       Creates accessor methods for manipulating hashes of key-value pairs.
591
592       Interfaces: The following calling interfaces are available.
593
594       default
595           Provides get_set behavior for *, and *_verb methods for most of the
596           other behaviors below.
597
598       get_set_items
599           Provides the get_set_items for *.
600
601       Behaviors: The following types of accessor methods are available.
602
603       get_set_items
604           Called with no arguments returns a reference to the hash stored.
605
606           Called with one simple scalar argument it treats the argument as a
607           key and returns the value stored under that key.
608
609           Called with more than one argument, treats them as a series of
610           key/value pairs and adds them to the hash.
611
612       get_push
613           Called with no arguments returns the hash stored, as a hash in a
614           list context or as a reference in a scalar context.
615
616           Called with one simple scalar argument it treats the argument as a
617           key and returns the value stored under that key.
618
619           Called with one array reference argument, the array elements are
620           considered to be be keys of the hash. x returns the list of values
621           stored under those keys (also known as a hash slice.)
622
623           Called with one hash reference argument, the keys and values of the
624           hash are added to the hash.
625
626           Called with more than one argument, treats them as a series of
627           key/value pairs and adds them to the hash.
628
629       get_set
630           Like get_push, except if called with more then one argument,
631           empties the current hash items before adding those arguments to the
632           hash.
633
634       push
635           Called with one hash reference argument, the keys and values of the
636           hash are added to the hash.
637
638           Called with more than one argument, treats them as a series of
639           key/value pairs and adds them to the hash.
640
641       keys
642           Returns a list of the keys of the hash.
643
644       values
645           Returns a list of the values in the hash.
646
647       tally
648           Takes a list of arguments and for each scalar in the list
649           increments the value stored in the hash and returns a list of the
650           current (after the increment) values.
651
652       exists
653           Takes a single key, returns whether that key exists in the hash.
654
655       delete
656           Takes a list, deletes each key from the hash, and returns the
657           corresponding values.
658
659       clear
660           Resets hash to empty.
661
662   tiedhash Accessor
663       A variant of Generic:hash which initializes the hash by tieing it to a
664       caller-specified package.
665
666       See the documentation on "Generic:hash" for interfaces and behaviors.
667
668       Parameters: The following parameters must be provided:
669
670       tie Required. The name of the class to tie to.  Make sure you have
671           "use"d the required class.
672
673       args
674           Required. Additional arguments for the tie, as an array ref.
675
676       Example:
677
678         use Class::MakeMethods
679           tie_hash => [ hits => { tie => q/Tie::RefHash/, args => [] } ];
680
681         use Class::MakeMethods
682           tie_hash => [ [qw(hits errors)] => { tie => q/Tie::RefHash/, args => [] } ];
683
684         use Class::MakeMethods
685           tie_hash => [ { name => hits, tie => q/Tie::RefHash/, args => [] } ];
686
687   hash_of_arrays Accessor
688       Creates accessor methods for manipulating hashes of array-refs.
689
690       Interfaces: The following calling interfaces are available.
691
692       default
693           Provides get behavior for *, and *_verb methods for the other
694           behaviors below.
695
696       Behaviors: The following types of accessor methods are available.
697
698       get Returns all the values for all the given keys, in order.  If no
699           keys are given, returns all the values (in an unspecified key
700           order).
701
702           The result is returned as an arrayref in scalar context.  This
703           arrayref is not part of the data structure; messing with it will
704           not affect the contents directly (even if a single key was provided
705           as argument.)
706
707           If any argument is provided which is an arrayref, then the members
708           of that array are used as keys.  Thus, the trivial empty-key case
709           may be utilized with an argument of [].
710
711       keys
712           Returns the keys of the hash.  As an arrayref in scalar context.
713
714       exists
715           Takes a list of keys, and returns whether all of the key exists in
716           the hash (i.e., the "and" of whether the individual keys exist).
717
718       delete
719           Takes a list, deletes each key from the hash.
720
721       push
722           Takes a key, and some values.  Pushes the values onto the list
723           denoted by the key.  If the first argument is an arrayref, then
724           each element of that arrayref is treated as a key and the elements
725           pushed onto each appropriate list.
726
727       pop Takes a list of keys, and pops each one.  Returns the list of
728           popped elements.  undef is returned in the list for each key that
729           is has an empty list.
730
731       unshift
732           Like push, only the from the other end of the lists.
733
734       shift
735           Like pop, only the from the other end of the lists.
736
737       splice
738           Takes a key, offset, length, and a values list.  Splices the list
739           named by the key.  Anything from the offset argument (inclusive)
740           may be omitted.  See "splice" in perlfunc.
741
742       clear
743           Takes a list of keys.  Resets each named list to empty (but does
744           not delete the keys.)
745
746       count
747           Takes a list of keys.  Returns the sum of the number of elements
748           for each named list.
749
750       index
751           Takes a key, and a list of indices.  Returns a list of each item at
752           the corresponding index in the list of the given key.  Uses undef
753           for indices beyond range.
754
755       remove
756           Takes a key, and a list of indices.  Removes each corresponding
757           item from the named list.  The indices are effectively looked up at
758           the point of call -- thus removing indices 3, 1 from list (a, b, c,
759           d) will remove (d) and (b).
760
761       sift
762           Takes a key, and a set of named arguments, which may be a list or a
763           hash ref.  Removes list members based on a grep-like approach.
764
765           filter
766               The filter function used (as a coderef).  Is passed two
767               arguments, the value compared against, and the value in the
768               list that is potential for grepping out.  If returns true, the
769               value is removed.  Default is "sub { $_[0] == $_[1] }".
770
771           keys
772               The list keys to sift through (as an arrayref).  Unknown keys
773               are ignored.  Default: all the known keys.
774
775           values
776               The values to sift out (as an arrayref).  Default: "[undef]"
777
778   object Accessor
779       Creates accessor methods for manipulating references to objects.
780
781       In addition to creating a method to get and set the object reference,
782       the meta-method can also define forwarded methods that automatically
783       pass calls onto the object stored in that slot; see the description of
784       the  'delegate' parameter below.
785
786       Interfaces: The following calling interfaces are available.
787
788       default
789           Provides get_set behavior for *, clear behavior for 'delete_*', and
790           forwarding methods for any values in the method's 'delegate' or
791           'soft_delegate' parameters.
792
793       get_and_set
794           Provides named get method, set_x and clear_x methods.
795
796       get_init_and_set
797           Provides named get_init method, set_x and clear_x methods.
798
799       Behaviors: The following types of accessor methods are available.
800
801       get_set
802           The get_set method, if called with a reference to an object of the
803           given class as the first argument, stores it.
804
805           If called with any other arguments, creates and stores a new
806           object, passing the arguemnts to the new() method for the object.
807
808           If called without arguments, returns the current value, which may
809           be undefined if one has not been stored yet.
810
811       get_set_init
812           The get_set_init method, if called with a reference to an object of
813           the given class as the first argument, stores it.
814
815           If the slot is not filled yet it creates an object by calling the
816           given new method of the given class. Any arguments passed to the
817           get_set_init method are passed on to new.
818
819           In all cases the object now stored is returned.
820
821       get_init
822           If the instance is empty, creates and stores a new one. Returns the
823           instance.
824
825       get Returns the current value, which may be undefined if one has not
826           been stored yet.
827
828       set If called with a reference to an object of the given class as the
829           first argument, stores it.
830
831           If called with any other arguments, creates and stores a new
832           object, passing the arguments to the new() method.
833
834           If called without arguments, creates and stores a new object,
835           without any arguments to the new() method.
836
837       clear
838           Removes the reference value.
839
840       forwarding
841           If a 'delegate' or 'soft_delegate' parameter is provided, methods
842           with those names are created that are forwarded directly to the
843           object in the slot, as described below.
844
845       Parameters: The following parameters are supported:
846
847       class
848           Required. The type of object that will be stored.
849
850       new_method
851           The name of the method to call on the above class to create a new
852           instance. Defaults to 'new'.
853
854       delegate
855           The methods to forward to the object. Can contain a method name, a
856           string of space-spearated method names, or an array of method
857           names. This type of method will croak if it is called when the
858           target object is not defined.
859
860       soft_delegate
861           The methods to forward to the object, if it is present. Can contain
862           a method name, a string of space-spearated method names, or an
863           array of method names. This type of method will return nothing if
864           it is called when the target object is not defined.
865
866   instance Accessor
867       Creates methods to handle an instance of the calling class.
868
869       PROFILES
870
871       default
872           Provides named get method, and verb_x set, new, and clear methods.
873
874       -implicit_new
875           Provides named get_init method, and verb_x set, and clear methods.
876
877       -x_verb
878           Provides named get method, and x_verb set, new, and clear methods.
879
880       Behaviors: The following types of accessor methods are available.
881
882       get Returns the value of the instance parameter, which may be undefined
883           if one has not been stored yet.
884
885       get_init
886           If the instance is empty, creates and stores a new one. Returns the
887           instance.
888
889       set Takes a single argument and sets the instance to that value.
890
891       new Creates and stores a new instance.
892
893       clear
894           Sets the instance parameter to undef.
895
896       Parameters: The following parameters are supported:
897
898       instance
899           Holds the instance reference. Defaults to undef
900
901       new_method
902           The name of the method to call when creating a new instance.
903           Defaults to 'new'.
904
905   array_of_objects Accessor
906       Creates accessor methods for manipulating references to arrays of
907       object references.
908
909       Operates like "Generic:array", but prior to adding any item to the
910       array, it first checks to see if it is an instance of the designated
911       class, and if not passes it as an argument to that class's new method
912       and stores the result instead.
913
914       Forwarded methods return a list of the results returned by "map"ing the
915       method over each object in the array.
916
917       See the documentation on "Generic:array" for interfaces and behaviors.
918
919       Parameters: The following parameters are supported:
920
921       class
922           Required. The type of object that will be stored.
923
924       delegate
925           The methods to forward to the object. Can contain a method name, a
926           string of space-spearated method names, or an array of method
927           names.
928
929       new_method
930           The name of the method to call on the above class to create a new
931           instance. Defaults to 'new'.
932
933   code Accessor
934       Creates accessor methods for manipulating references to subroutines.
935
936       Interfaces: The following calling interfaces are available.
937
938       default
939           Provides the call_set functionality.
940
941       method
942           Provides the call_method functionality.
943
944       Behaviors: The following types of accessor methods are available.
945
946       call_set
947           If called with one argument which is a CODE reference, it installs
948           that code in the slot. Otherwise it runs the code stored in the
949           slot with whatever arguments (including none) were passed in.
950
951       call_method
952           Just like call_set, except the code is called like a method, with
953           $self as its first argument. Basically, you are creating a method
954           which can be different for each object.
955
956   code_or_scalar Accessor
957       Creates accessor methods for manipulating either strings or references
958       to subroutines.
959
960       You can store any scalar value; code refs are executed when you
961       retrieve the value, while other scalars are returned as-is.
962
963       Interfaces: The following calling interfaces are available.
964
965       default
966           Provides the call_set functionality.
967
968       method
969           Provides the call_method functionality.
970
971       eiffel
972           Provides the named get_method, and a helper set_* method.
973
974       Behaviors: The following types of accessor methods are available.
975
976       get_set_call
977           If called with an argument, either a CODE reference or some other
978           scalar, it installs that code in the slot. Otherwise, if the
979           current value  runs the code stored in the slot with whatever
980           arguments (including none) were passed in.
981
982       get_set_method
983           Just like call_set, except the code is called like a method, with
984           $self as its first argument. Basically, you are creating a method
985           which can be different for each object.
986

SEE ALSO

988       See Class::MakeMethods for general information about this distribution.
989
990       See Class::MakeMethods::Template for information about this family of
991       subclasses.
992

POD ERRORS

994       Hey! The above document had some coding errors, which are explained
995       below:
996
997       Around line 939:
998           You forgot a '=back' before '=head2'
999
1000
1001
1002perl v5.32.0                      2020-07-28 MakeMethods::Template::Generic(3)
Impressum