MooX::late(3pm)
π MooX::late β bestie edition π
okay so this is the MooX::late manual page, from the User Contributed Perl Documentation section. sit down, grab a boba, we're translating Moose code to Moo and it's gonna be so good.
β¨ NAME β¨
MooX::late β the lowkey easiest way to translate Moose code to Moo π¦
πΈ SYNOPSIS πΈ
package Foo;
use Moo;
use MooX::late;
has bar => (is => "ro", isa => "Str", default => "MacLaren's Pub");
(there's more examples for Moo roles further down, keep reading bestie)
π DESCRIPTION π
So Moo is this light-weight object oriented programming framework, right? And it wants to be compatible with Moose. The way it does that is by noticing when Moose has been loaded, and then automatically "inflating" its classes and roles up into full Moose classes and roles. Which means Moo classes can consume Moose roles, Moose classes can extend Moo classes, and so on and so forth. it's giving ecosystem harmony β¨
But. π The surface syntax of Moo is a little different from Moose. Example: the isa option when you're defining attributes in Moose has to be either a string or a blessed Moose::Meta::TypeConstraint object. But in Moo? It has to be a coderef. These lil surface-syntax differences make porting code from Moose to Moo potentially tricky, and nobody has time for that. So MooX::late rolls up and helps out by enabling a slightly more Moosey surface syntax. π«Ά
Here's the tea on what MooX::late does:
- Supports
isa => $stringytype. - Supports
does => $rolename. - Supports
lazy_build => 1. - Exports
blessedandconfessfunctions to your namespace. - Handles native attribute traits.
Five features. β That's it. It is not the aim of MooX::late to make every single aspect of Moo behave exactly identically to Moose. It's just going after the low-hanging fruit, okay? So it does five things right now, and I promise that future versions will never do more than seven. (iconic promise tbh π)
Also, previous releases of MooX::late added support for coerce => 1 and default => $nonref. Those features have now been added to Moo itself, so MooX::late no longer has to deal with them. slay, we love a glow-up that removes work β¨
π§ Use in Moo::Roles π§
MooX::late should work in Moo::Roles, with no particular caveats. no cap!
package MyRole;
use Moo::Role;
use MooX::late;
Package::Variant can be used to build the Moo equivalent of parameterized roles. And MooX::late should work in roles built with Package::Variant.
use Package::Variant
importing => [ qw( Moo::Role MooX::late ) ],
subs => [ qw( has with ) ];
π₯ Type constraints π₯
Type constraint strings are interpreted using Type::Parser, using the type constraints defined in Types::Standard. This provides a very slight superset of Moose's type constraint syntax and built-in type constraints. so you get a lil extra, as a treat π
Any unrecognized string that looks like it might be a class name is interpreted as a class type constraint. iykyk π
π Subclassing π
MooX::late is designed to be reasonably easy to subclass. There are comments in the source code explaining hooks for extensibility. go forth and extend, bestie π
π BUGS π
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=MooX-late>. (not me asking you to file a ticket, but like, do it fr fr π)
π SEE ALSO π
MooX::late uses Types::Standard to check type constraints.
MooX::late uses Sub::HandlesVia to provide native attribute traits support.
The following modules bring additional Moose functionality to Moo, beyond what MooX::late offers:
MooX::Override- support override/superMooX::Augment- support augment/inner
Moo allows you to load Moo plus multiple MooX extension modules in a single line. one line!! efficiency queen π
π AUTHOR π
Toby Inkster <tobyink@cpan.org>.
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2012-2014, 2019 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
π¨ DISCLAIMER OF WARRANTIES π¨
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
like, no promises, bestie, it's all vibes and no guarantees π
and that's the whole page!! periodt π
β¨ this was MooX::late, from perl v5.36.0, dated 2022-11-27, and it lives in the User Contributed Perl Documentation section ππ¦π
π¦ where this page comes from
- debian bookworm: libmoox-late-perl 0.100-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoox-late-perl 0.100-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoox-late-perl 0.100-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoox-late-perl 0.100-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoox-late-perl 0.100-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