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 meta-
27       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
34           something 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
38           implementations, 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       The following methods from Generic are all supported:
54
55         new
56         scalar
57         string
58         string_index
59         number
60         boolean
61         bits (*)
62         array
63         hash
64         tiedhash
65         hash_of_arrays
66         object
67         instance
68         array_of_objects
69         code
70         code_or_scalar
71
72       See Class::MakeMethods::Template::Generic for the interfaces and
73       behaviors of these method types.
74
75       The items marked with a * above are specifically defined in this
76       package, whereas the others are formed automatically by the interaction
77       of this package's generic settings with the code templates provided by
78       the Generic superclass.
79
80   struct
81         struct => [ qw / foo bar baz / ];
82
83       Creates methods for setting, checking and clearing values which are
84       stored by position in an array. All the slots created with this meta-
85       method are stored in a single array.
86
87       The argument to struct should be a string or a reference to an array of
88       strings. For each string meta-method x, it defines two methods: x and
89       clear_x. x returns the value of the x-slot.  If called with an
90       argument, it first sets the x-slot to the argument.  clear_x sets the
91       slot to undef.
92
93       Additionally, struct defines three class method: struct, which returns
94       a list of all of the struct values, struct_fields, which returns a list
95       of all the slots by name, and struct_dump, which returns a hash of the
96       slot-name/slot-value pairs.
97

SEE ALSO

99       See Class::MakeMethods for general information about this distribution.
100
101       See Class::MakeMethods::Template for more about this family of
102       subclasses.
103
104       See Class::MakeMethods::Template::Generic for information about the
105       various accessor interfaces subclassed herein.
106
107
108
109perl v5.32.0                      2020-07-28    MakeMethods::Template::Hash(3)
Impressum