Mason:...::Moose(3pm)

πŸ“¦
version 2.24 Β· 2 versions
  • 2.24 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 2.24 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 πŸ‘‘


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