Mason:...classes(3pm)
β¨ NAME β¨
Mason::Manual::Subclasses β it's giving make your own custom subclasses of Mason's classes π bestie, you're about to build your own little Mason dynasty
π¦ DESCRIPTION π¦
okay so, plot twist: you can totally subclass these Mason classes for your app π
Mason::CodeCache
Mason::Compilation
Mason::Component
Mason::Component::ClassMeta
Mason::Component::Import
Mason::Component::Moose
Mason::Interp
Mason::Request
Mason::Result
...and then arrange everything so Mason always reaches for your subclass instead of its default class. main character energy, honestly. π
Note: if what you want is a general purpose modification to Mason that you'd use across multiple applications, you should probably create a plugin instead of a subclass. iykyk. π§
π CREATING A SUBCLASS π
a subclass should look something like this:
package My::Mason::Interp;
use Moose;
extends 'Mason::Interp';
# put your modifications here
1;
so simple, so clean, no cap π
πΈ LETTING MASON KNOW ABOUT YOUR SUBCLASSES πΈ
there are two ways to let Mason know about your subclasses: by naming convention, and by parameters to Mason->new. two options, both iconic, pick your fighter π«Ά
π By naming convention
first, create a subclass of Mason itself:
package My::Mason;
use Moose;
extends 'Mason';
1;
and then use that in place of Mason when you construct:
my $interp = My::Mason->new();
now here's the slay part: you can place any subclasses under 'My::Mason' and they'll automatically be picked up. literally automatic. e.g.
My::Mason::Compilation
My::Mason::Interp
My::Mason::Request
β By constructor parameter
orrr you can specify your subclasses via base_* parameters to Mason->new(). e.g.
my $interp = Mason->new(
base_compilation_class => 'My::Mason::Compilation',
base_interp_class => 'My::Mason::Interp'
base_request_class => 'Some::Other::Mason::Request'
);
see "CUSTOM MASON CLASSES" in Mason::Interp for a complete list. go look, it's worth it π
π SEE ALSO π
Mason
π AUTHOR π
Jonathan Swartz <swartz@pobox.com>
π 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. periodt. π
and that's the whole vibe bestie β this page came to you from the perl v5.34.0 docs, dated 2022-05-27, filed under Mason:...classes(3pm) in the User Contributed Perl Documentation. 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