1HTML::Mason::MethodMakeUrs(e3r)Contributed Perl DocumentHaTtMiLo:n:Mason::MethodMaker(3)
2
3
4
6 HTML::Mason::MethodMaker - Used to create simple get & get/set methods
7 in other classes
8
10 use HTML::Mason::MethodMaker
11 ( read_only => 'foo',
12 read_write => [
13 [ bar => { type => SCALAR } ],
14 [ baz => { isa => 'HTML::Mason::Baz' } ],
15 'quux', # no validation
16 ],
17 read_write_contained => { other_object =>
18 [
19 [ 'thing1' => { isa => 'Thing1' } ],
20 'thing2', # no validation
21 ]
22 },
23 );
24
26 This automates the creation of simple accessor methods.
27
29 This module creates methods when it is "use"'d by another module.
30 There are three types of methods: 'read_only', 'read_write',
31 'read_write_contained'.
32
33 Attributes specified as 'read_only' get an accessor that only returns
34 the value of the attribute. Presumably, these attributes are set via
35 more complicated methods in the class or as a side effect of one of its
36 methods.
37
38 Attributes specified as 'read_write' will take a single optional param‐
39 eter. If given, this parameter will become the new value of the
40 attribute. This value is then returned from the method. If no parame‐
41 ter is given, then the current value is returned.
42
43 If you want the accessor to use "Params::Validate" to validate any val‐
44 ues passed to the accessor (and you _do_), then the the accessor speci‐
45 fication should be an array reference containing two elements. The
46 first element is the accessor name and the second is the validation
47 spec.
48
49 The 'read_write_contained' parameter is used to create accessor for
50 delayed contained objects. A delayed contained object is one that is
51 not created in the containing object's accessor, but rather at some
52 point after the containing object is constructed. For example, the
53 Interpreter object creates Request objects after the Interpreter itself
54 has been created.
55
56 The value of the 'read_write_contained' parameter should be a hash ref‐
57 erence. The keys are the internal name of the contained object, such
58 as "request" or "compiler". The values for the keys are the same as
59 the parameters given for 'read_write' accessors.
60
62 HTML::Mason
63
64
65
66perl v5.8.8 2007-04-17 HTML::Mason::MethodMaker(3)