1MooX::late(3) User Contributed Perl Documentation MooX::late(3)
2
3
4
6 MooX::late - easily translate Moose code to Moo
7
9 package Foo;
10 use Moo;
11 use MooX::late;
12 has bar => (is => "ro", isa => "Str", default => "MacLaren's Pub");
13
14 (Examples for Moo roles in section below.)
15
17 Moo is a light-weight object oriented programming framework which aims
18 to be compatible with Moose. It does this by detecting when Moose has
19 been loaded, and automatically "inflating" its classes and roles to
20 full Moose classes and roles. This way, Moo classes can consume Moose
21 roles, Moose classes can extend Moo classes, and so forth.
22
23 However, the surface syntax of Moo differs somewhat from Moose. For
24 example the "isa" option when defining attributes in Moose must be
25 either a string or a blessed Moose::Meta::TypeConstraint object; but in
26 Moo must be a coderef. These differences in surface syntax make porting
27 code from Moose to Moo potentially tricky. MooX::late provides some
28 assistance by enabling a slightly more Moosey surface syntax.
29
30 MooX::late does the following:
31
32 1. Supports "isa => $stringytype".
33
34 2. Supports "does => $rolename" .
35
36 3. Supports "lazy_build => 1".
37
38 4. Exports "blessed" and "confess" functions to your namespace.
39
40 5. Handles native attribute traits.
41
42 Five features. It is not the aim of "MooX::late" to make every aspect
43 of Moo behave exactly identically to Moose. It's just going after the
44 low-hanging fruit. So it does five things right now, and I promise that
45 future versions will never do more than seven.
46
47 Previous releases of MooX::late added support for "coerce => 1" and
48 "default => $nonref". These features have now been added to Moo itself,
49 so MooX::late no longer has to deal with them.
50
51 Use in Moo::Roles
52 MooX::late should work in Moo::Roles, with no particular caveats.
53
54 package MyRole;
55 use Moo::Role;
56 use MooX::late;
57
58 Package::Variant can be used to build the Moo equivalent of
59 parameterized roles. MooX::late should work in roles built with
60 Package::Variant.
61
62 use Package::Variant
63 importing => [ qw( Moo::Role MooX::late ) ],
64 subs => [ qw( has with ) ];
65
66 Type constraints
67 Type constraint strings are interpreted using Type::Parser, using the
68 type constraints defined in Types::Standard. This provides a very
69 slight superset of Moose's type constraint syntax and built-in type
70 constraints.
71
72 Any unrecognized string that looks like it might be a class name is
73 interpreted as a class type constraint.
74
75 Subclassing
76 MooX::late is designed to be reasonably easy to subclass. There are
77 comments in the source code explaining hooks for extensibility.
78
80 Please report any bugs to
81 <http://rt.cpan.org/Dist/Display.html?Queue=MooX-late>.
82
84 "MooX::late" uses Types::Standard to check type constraints.
85
86 "MooX::late" uses Sub::HandlesVia to provide native attribute traits
87 support.
88
89 The following modules bring additional Moose functionality to Moo,
90 beyond what MooX::late offers:
91
92 • MooX::Override - support override/super
93
94 • MooX::Augment - support augment/inner
95
96 MooX allows you to load Moo plus multiple MooX extension modules in a
97 single line.
98
100 Toby Inkster <tobyink@cpan.org>.
101
103 This software is copyright (c) 2012-2014, 2019 by Toby Inkster.
104
105 This is free software; you can redistribute it and/or modify it under
106 the same terms as the Perl 5 programming language system itself.
107
109 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
110 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
111 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
112
113
114
115perl v5.34.0 2022-01-26 MooX::late(3)