17 Feb 2020 17:19:11 UTC
- Distribution: MooX-late
- Module version: 0.100
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (71 / 0 / 1)
- KwaliteeBus factor: 1
- 82.56% Coverage
- License: perl_5
- Perl: v5.8.3
- Activity24 month
- Download (21.59KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- SEE ALSO
- COPYRIGHT AND LICENCE
- DISCLAIMER OF WARRANTIES
MooX::late - easily translate Moose code to Moo
package Foo; use Moo; use MooX::late; has bar => (is => "ro", isa => "Str", default => "MacLaren's Pub");
(Examples for Moo roles in section below.)
Moo is a light-weight object oriented programming framework which aims to be compatible with Moose. It does this by detecting when Moose has been loaded, and automatically "inflating" its classes and roles to full Moose classes and roles. This way, Moo classes can consume Moose roles, Moose classes can extend Moo classes, and so forth.
However, the surface syntax of Moo differs somewhat from Moose. For example the
isaoption when defining attributes in Moose must be either a string or a blessed Moose::Meta::TypeConstraint object; but in Moo must be a coderef. These differences in surface syntax make porting code from Moose to Moo potentially tricky. MooX::late provides some assistance by enabling a slightly more Moosey surface syntax.
MooX::late does the following:
isa => $stringytype.
does => $rolename.
lazy_build => 1.
confessfunctions to your namespace.
Handles native attribute traits.
Five features. It is not the aim of
MooX::lateto make every aspect of Moo behave exactly identically to Moose. It's just going after the low-hanging fruit. So it does five things right now, and I promise that future versions will never do more than seven.
Previous releases of MooX::late added support for
coerce => 1and
default => $nonref. These features have now been added to Moo itself, so MooX::late no longer has to deal with them.
MooX::late should work in Moo::Roles, with no particular caveats.
package MyRole; use Moo::Role; use MooX::late;
Package::Variant can be used to build the Moo equivalent of parameterized roles. MooX::late should work in roles built with Package::Variant.
use Package::Variant importing => [ qw( Moo::Role MooX::late ) ], subs => [ qw( has with ) ];
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.
Any unrecognized string that looks like it might be a class name is interpreted as a class type constraint.
MooX::late is designed to be reasonably easy to subclass. There are comments in the source code explaining hooks for extensibility.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=MooX-late.
MooX::lateuses Types::Standard to check type constraints.
MooX::lateuses Sub::HandlesVia to provide native attribute traits support.
The following modules bring additional Moose functionality to Moo, beyond what MooX::late offers:
MooX allows you to load Moo plus multiple MooX extension modules in a single line.
Toby Inkster <firstname.lastname@example.org>.
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.
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.