.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTML::Mason::MethodMaker 3pm" .TH HTML::Mason::MethodMaker 3pm 2024-03-05 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME HTML::Mason::MethodMaker \- Used to create simple get & get/set methods in other classes .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 10 \& use HTML::Mason::MethodMaker \& ( read_only => \*(Aqfoo\*(Aq, \& read_write => [ \& [ bar => { type => SCALAR } ], \& [ baz => { isa => \*(AqHTML::Mason::Baz\*(Aq } ], \& \*(Aqquux\*(Aq, # no validation \& ], \& read_write_contained => { other_object => \& [ \& [ \*(Aqthing1\*(Aq => { isa => \*(AqThing1\*(Aq } ], \& \*(Aqthing2\*(Aq, # no validation \& ] \& }, \& ); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This automates the creation of simple accessor methods. .SH USAGE .IX Header "USAGE" This module creates methods when it is \f(CW\*(C`use\*(C'\fR'd by another module. There are three types of methods: 'read_only', 'read_write', \&'read_write_contained'. .PP Attributes specified as 'read_only' get an accessor that only returns the value of the attribute. Presumably, these attributes are set via more complicated methods in the class or as a side effect of one of its methods. .PP Attributes specified as 'read_write' will take a single optional parameter. If given, this parameter will become the new value of the attribute. This value is then returned from the method. If no parameter is given, then the current value is returned. .PP If you want the accessor to use \f(CW\*(C`Params::Validate\*(C'\fR to validate any values passed to the accessor (and you _do_), then the the accessor specification should be an array reference containing two elements. The first element is the accessor name and the second is the validation spec. .PP The 'read_write_contained' parameter is used to create accessor for delayed contained objects. A \fIdelayed\fR contained object is one that is \fBnot\fR created in the containing object's accessor, but rather at some point after the containing object is constructed. For example, the Interpreter object creates Request objects after the Interpreter itself has been created. .PP The value of the 'read_write_contained' parameter should be a hash reference. The keys are the internal name of the contained object, such as "request" or "compiler". The values for the keys are the same as the parameters given for 'read_write' accessors.