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
39 parameter. If given, this parameter will become the new value of the
40 attribute. This value is then returned from the method. If no
41 parameter is given, then the current value is returned.
42
43 If you want the accessor to use "Params::Validate" to validate any
44 values passed to the accessor (and you _do_), then the the accessor
45 specification should be an array reference containing two elements.
46 The 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
57 reference. The keys are the internal name of the contained object,
58 such as "request" or "compiler". The values for the keys are the same
59 as the parameters given for 'read_write' accessors.
60
61
62
63perl v5.30.0 2019-07-26 HTML::Mason::MethodMaker(3)