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

SEE ALSO

1018       See Class::MakeMethods for general information about this distribution.
1019
1020       See Class::MakeMethods::Template for information about this family of
1021       subclasses.
1022
1023
1024
1025perl v5.8.8                       2004-09-06 MakeMethods::Template::Generic(3)
Impressum