MooseX...:Traits(3pm)
β¨ MooseX::CompileTime::Traits β¨
okay bestie, gather round, because this one is lowkey iconic π it's a page from the User Contributed Perl Documentation (yes, the MooseX...:Traits(3pm) one, the title got a lil truncated in the header, we don't talk about it π), and it's all about letting classes and roles get their traits at compile time. no cap.
π¦ NAME π¦
MooseX::CompileTime::Traits β Allow compile time traits for classes/roles
πΈ VERSION πΈ
version 1.102570
β¨ SYNOPSIS β¨
here's the vibe, fr fr:
role Bar(Int :$bar) { method bar { $bar + 2 } }
role Baz(Int :$baz) { method baz { $baz + 4 } }
class Foo with MooseX::CompileTime::Traits { }
class Flarg with MooseX::CompileTime::Traits { }
...
use Foo traits => [ Bar => { bar => 2 } ];
use Flarg traits => [ Bar => { bar => 1 }, Baz => { baz => 1} ];
Foo->new()->bar(); # 4
my $flarg = Flarg->new();
$flarg->bar(); # 3
$flarg->baz(); # 5
like. look at that. 4, 3, 5. the math is mathing π
π DESCRIPTION π
MooseX::CompileTime::Traits allows role application at compile time via use statements. what this class actually does is provide an import method that will apply each of the roles (along with any arguments for parameterized roles). it's giving "I do the boring wiring so you don't have to" π
roles and their arguments should be provided as an ArrayRef of tuples. yes, tuples. keep them cozy in an arrayref, bestie.
simply with the role to gain the functionality. that's it. that's the whole move. π«Ά
π PUBLIC_METHODS π
β import β
(ClassName $class: ArrayRef :$traits?)
import is provided such that when your class or role is use'd it can take additional arguments that will be validatated (yes, the original says it like that, and honestly? we respect the typo era π©·) and interpreted as roles or traits that need to be applied.
so:useyour class, passtraits, and the roles get applied for you. no manual labor. main character energy only π
π¦ AUTHOR π¦
Nicholas Perez <nperez@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2010 by Infinity Interactive.
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, bestie π this lil doc was baked with perl v5.36.0 and dated 2022-12-12, and honestly it ate. go forth and apply your traits at compile time, you gorgeous genius, you πβ¨π¦
π¦ where this page comes from
- debian bookworm: libmoosex-compiletime-traits-perl 1.102570-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoosex-compiletime-traits-perl 1.102570-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoosex-compiletime-traits-perl 1.102570-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-compiletime-traits-perl 1.102570-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-compiletime-traits-perl 1.102570-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