1MakeMethods::Template::UHsaesrh(C3o)ntributed Perl DocumMeankteaMteitohnods::Template::Hash(3)
2
3
4

NAME

6       Class::MakeMethods::Template::Hash - Method interfaces for hash-based
7       objects
8

SYNOPSIS

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

DESCRIPTION

23       These meta-methods create and access values within blessed hash
24       objects.
25
26       Common Parameters: The following parameters are defined for Hash
27       meta-methods.
28
29       hash_key
30           The hash key to use when retrieving values from each hash instance.
31           Defaults to '*', the name of the meta-method.
32
33           Changing this allows you to change an accessor method name to some‐
34           thing other than the name of the hash key used to retrieve its
35           value.
36
37           Note that this parameter is not portable to the other implementa‐
38           tions, such as Global or InsideOut.
39
40           You can take advantage of parameter expansion to define methods
41           whose hash key is composed of the defining package's name and the
42           individual method name, such as "$self->{MyObject-foo}":
43
44                 'hash_key' => '*{target_class}-*{name}'
45
46       Common Behaviors
47
48       Behavior: delete
49           Deletes the named key and associated value from the current hash
50           instance.
51
52       Standard Methods
53
54       The following methods from Generic are all supported:
55
56         new
57         scalar
58         string
59         string_index
60         number
61         boolean
62         bits (*)
63         array
64         hash
65         tiedhash
66         hash_of_arrays
67         object
68         instance
69         array_of_objects
70         code
71         code_or_scalar
72
73       See Class::MakeMethods::Template::Generic for the interfaces and behav‐
74       iors of these method types.
75
76       The items marked with a * above are specifically defined in this pack‐
77       age, whereas the others are formed automatically by the interaction of
78       this package's generic settings with the code templates provided by the
79       Generic superclass.
80
81       struct
82
83         struct => [ qw / foo bar baz / ];
84
85       Creates methods for setting, checking and clearing values which are
86       stored by position in an array. All the slots created with this meta-
87       method are stored in a single array.
88
89       The argument to struct should be a string or a reference to an array of
90       strings. For each string meta-method x, it defines two methods: x and
91       clear_x. x returns the value of the x-slot.  If called with an argu‐
92       ment, it first sets the x-slot to the argument.  clear_x sets the slot
93       to undef.
94
95       Additionally, struct defines three class method: struct, which returns
96       a list of all of the struct values, struct_fields, which returns a list
97       of all the slots by name, and struct_dump, which returns a hash of the
98       slot-name/slot-value pairs.
99

SEE ALSO

101       See Class::MakeMethods for general information about this distribution.
102
103       See Class::MakeMethods::Template for more about this family of sub‐
104       classes.
105
106       See Class::MakeMethods::Template::Generic for information about the
107       various accessor interfaces subclassed herein.
108
109
110
111perl v5.8.8                       2004-09-06    MakeMethods::Template::Hash(3)
Impressum