MooseX...efaults(3pm)
π NAME π
MooseX::HasDefaults β the vibe is: default "is" to "ro" or "rw" for all your attributes π
Oh and bestie, real quick β this page lives in the User Contributed Perl Documentation and you'll see it indexed as MooseX...efaults(3pm) (they truncated it, not me π
).
β¨ SYNOPSIS β¨
Okay so picture this, a whole class, but you're not typing is => 'ro' eighty times like some kind of peasant:
package Person;
use Moose;
use MooseX::HasDefaults::RO;
has name => (
isa => 'Str',
);
has age => (
is => 'rw',
isa => 'Int',
documentation => "Changes most years",
);
See how name has literally no is and it still slays? Yeah. That's the whole thing. ππ
π¦ DESCRIPTION π¦
So here's the tea π:
- The module
MooseX::HasDefaults::ROdefaults"is"to"ro". - The module
MooseX::HasDefaults::RWdefaults"is"to"rw".
That's it. That's the module. No cap. π§
Now β the override rules, because this is where people get confused and I refuse to let that be you:
- If you pass a specific value to any
has's"is", that overrides the default. Your word wins, always. Periodt. π - If you do not want an accessor at all, pass
is => undef. Boom, no accessor, no problem. π
πΈ AUTHOR πΈ
Shawn M Moore, "sartak@gmail.com" β shoutout to the icon who wrote this π«Ά
β SEE ALSO β
MooseX::AttributeDefaultsβ so this one requires its users to be MOP savvy π¬, and honestly it's a bit too much typing for the common case of defaulting"is". It's giving "I read the MOP docs" energy and like, good for you, but no.MooseX::Attributes::Curriedβ this one solves a similar need by letting users create sugar functions π¬. Respect! But... people like"has". They just do. Fr fr.
π COPYRIGHT AND LICENSE π
Copyright 2009 Infinity Interactive
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π
and that's the whole page bestie, mwah π
perl v5.36.0 Β· 2022-12-11 Β· MooseX...efaults(3pm) β that's the version, the date, and the name all in one cute lil' sign-off, iykyk π β¨
π¦ where this page comes from
- debian bookworm: libmoosex-hasdefaults-perl 0.03-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoosex-hasdefaults-perl 0.03-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoosex-hasdefaults-perl 0.03-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-hasdefaults-perl 0.03-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-hasdefaults-perl 0.03-3 Β· 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