HTML::...dMaker(3pm)
π HTML::...dMaker(3pm) π
User Contributed Perl Documentation β¨ so this is the page for HTML::Mason::MethodMaker, bestie π
π NAME π
HTML::Mason::MethodMaker β it's the lil module that makes simple get & get/set methods for other classes π«Ά
πΈ SYNOPSIS πΈ
use HTML::Mason::MethodMaker
( read_only => 'foo',
read_write => [
[ bar => { type => SCALAR } ],
[ baz => { isa => 'HTML::Mason::Baz' } ],
'quux', # no validation
],
read_write_contained => { other_object =>
[
[ 'thing1' => { isa => 'Thing1' } ],
'thing2', # no validation
]
},
);
okay look at that, it's giving effortless β¨
π¦ DESCRIPTION π¦
This automates the creation of simple accessor methods. that's it. that's the whole vibe π like, you do NOT need to hand-write thirty little sub foo { ... } blocks, no cap π
π USAGE π
This module creates methods when it is use'd by another module. There are three types of methods: 'read_only', 'read_write', 'read_write_contained'. three flavors, pick ur fighter π§
β read_only β
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.
so like... it's read-only fr fr, you can look but you cannot touch π the class itself is the one setting that value behind the scenes, not you.
π read_write π
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.
it's giving dual-purpose icon behavior π pass nothing β you get the value. pass something β that something becomes the value, and then it gets returned to you. one method, two jobs, main character energy β¨
π validation, aka the Params::Validate moment π
If you want the accessor to use Params::Validate 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.
bestie, please validate. it says you _do_ want this. it's italicized-and-underscored in the original, that's how serious it is π so: array ref, element one = accessor name, element two = the validation spec. two things. that's the whole deal π
π«Ά read_write_contained π«Ά
The 'read_write_contained' parameter is used to create accessor for delayed contained objects. A delayed contained object is one that is not 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.
okay so delayed contained objects β not built at the moment the container's accessor runs, but lowkey later, after the containing object already exists. the glow-up happens off-screen π example straight from the source: the Interpreter object creates Request objects after the Interpreter itself has been created. iconic scheduling ngl β¨
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.
so: hash ref. keys = the internal name of the contained object (think"request","compiler"). values = literally the exact same stuff you'd hand to a'read_write'accessor. reuse the formula, it ate π₯
and that's the whole page, you understood it, periodt πβ¨π
this was HTML::...dMaker(3pm) from the User Contributed Perl Documentation crew, running on perl v5.38.2, dated 2024-03-05 πΈ mwah, go write some accessors bestie π«Άπ
π¦ where this page comes from
- debian trixie: libhtml-mason-perl 1:1.60-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-mason-perl 1:1.60-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-mason-perl 1:1.60-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms