Mason:...::Moose(3pm)
π Mason::Component::Moose β perl v5.34.0, you're gonna eat this up π
okay bestie, so this is Mason::Component::Moose, which lives in the Perl 5 user-contributed docs (that's the 3pm situation β module docs, iykyk). Buckle up, it's short and it slaps.
β¨ NAME β¨
Mason::Component::Moose β Moose policies and exports for Mason components. π
π¦ DESCRIPTION π¦
So here's the tea: this module gets automatically included in every single generated Mason component class. You don't have to do anything. It just shows up. Main character energy fr fr.
And it's equivalent to writing all of this yourself:
use CLASS;
use Moose;
use MooseX::HasDefaults::RW;
use Method::Signatures::Simple;
That's it. That's the whole vibe. Four lines of pure slay, done for you every time. π
π OVERRIDING π
Now if you're feeling β¨extraβ¨ and you want to change the default behavior? Totally valid. You just subclass this class and pass it as base_component_moose_class to Mason::Interp.
Like, for example, if you wanted MooseX::StrictConstructor in every single component, you'd do this:
package My::Mason::Component::Moose;
use Moose::Exporter;
use MooseX::StrictConstructor ();
use base qw(Mason::Component::Moose);
sub init_meta {
my $class = shift;
$class->SUPER::init_meta(@_);
MooseX::StrictConstructor->init_meta(@_);
}
...
my $interp = Mason::Interp->new(..., base_component_moose_class => 'My::Mason::Component::Moose');
Not me being obsessed with the SUPER:: call β don't skip it, bestie, or you'll lose the base behavior and that's a whole tragedy. π
πΈ SEE ALSO πΈ
Masonβ go read it, it's the parent situation
π«Ά AUTHOR π«Ά
Jonathan Swartz <swartz@pobox.com> β thank you for your service, king π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2012 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. π
and that's the whole page, no cap. perl v5.34.0, dated 2022-05-27 β shoutout to the Perl 5 docs for keeping it iconic all these years. mwah πβ¨π¦
π¦ where this page comes from
- debian bookworm: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmason-perl 2.24-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