1MooseX::Extended::Role(U3s)er Contributed Perl DocumentatMiooonseX::Extended::Role(3)
2
3
4

NAME

6       MooseX::Extended::Role - MooseX::Extended roles
7

VERSION

9       version 0.35
10

SYNOPSIS

12           package Not::Corinna::Role::Created {
13               use MooseX::Extended::Role types => ['PositiveInt'];
14
15               field created => ( isa => PositiveInt, default => sub { time } );
16           }
17
18       Similar to MooseX::Extended, providing almost everything that module
19       provides.  However, for obvious reasons, it does not include
20       MooseX::StrictConstructor or make your class immutable, or set the C3
21       mro.
22
23       Note that there is no need to add a 1 at the end of the role.
24

CONFIGURATION

26       You may pass an import list to MooseX::Extended::Role.
27
28           use MooseX::Extended::Role
29             excludes => [qw/WarnOnConflict carp/],         # I don't want these features
30             types    => [qw/compile PositiveInt HashRef/]; # I want these type tools
31
32   "types"
33       Allows you to import any types provided by MooseX::Extended::Types.
34
35       This:
36
37           use MooseX::Extended::Role types => [qw/compile PositiveInt HashRef/];
38
39       Is identical to this:
40
41           use MooseX::Extended::Role;
42           use MooseX::Extended::Types qw( compile PositiveInt HashRef );
43
44   "excludes"
45       You may find some features to be annoying, or even cause potential bugs
46       (e.g., if you have a `croak` method, our importing of "Carp::croak"
47       will be a problem. You can exclude the following:
48
49       •   "WarnOnConflict"
50
51               use MooseX::Extended::Role excludes => ['WarnOnConflict'];
52
53           Excluding this removes the "MooseX::Role::WarnOnConflict" role.
54
55       •   "autoclean"
56
57               use MooseX::Extended::Role excludes => ['autoclean'];
58
59           Excluding this will no longer import "namespace::autoclean".
60
61       •   "carp"
62
63               use MooseX::Extended::Role excludes => ['carp'];
64
65           Excluding this will no longer import "Carp::croak" and
66           "Carp::carp".
67
68       •   "true"
69
70               use MooseX::Extended::Role excludes => ['true'];
71
72           Excluding this will require your module to end in a true value.
73
74       •   "param"
75
76               use MooseX::Extended::Role excludes => ['param'];
77
78           Excluding this will make the "param" function unavailable.
79
80       •   "field"
81
82               use MooseX::Extended::Role excludes => ['field'];
83
84           Excluding this will make the "field" function unavailable.
85
86   "includes"
87       Some experimental features are useful, but might not be quite what you
88       want.
89
90           use MooseX::Extended::Role includes => [qw/multi/];
91
92           multi sub foo ($self, $x)      { ... }
93           multi sub foo ($self, $x, $y ) { ... }
94
95       See MooseX::Extended::Manual::Includes for more information.
96

IDENTICAL METHOD NAMES IN CLASSES AND ROLES

98       In Moose if a class defines a method of the name as the method of a
99       role it's consuming, the role's method is silently discarded. With
100       MooseX::Extended::Role, you get a warning. This makes maintenance
101       easier when to prevent you from accidentally overriding a method.
102
103       For example:
104
105           package My::Role {
106               use MooseX::Extended::Role;
107
108               sub name {'Ovid'}
109           }
110
111           package My::Class {
112               use MooseX::Extended;
113               with 'My::Role';
114               sub name {'Bob'}
115           }
116
117       The above code will still run, but you'll get a very verbose warning:
118
119           The class My::Class has implicitly overridden the method (name) from
120           role My::Role. If this is intentional, please exclude the method from
121           composition to silence this warning (see Moose::Cookbook::Roles::Recipe2)
122
123       To silence the warning, just be explicit about your intent:
124
125           package My::Class {
126               use MooseX::Extended;
127               with 'My::Role' => { -excludes => ['name'] };
128               sub name {'Bob'}
129           }
130
131       Alternately, you can exclude this feature. We don't recommend this, but
132       it might be useful if you're refactoring a legacy Moose system.
133
134           use MooseX::Extended::Role excludes => [qw/WarnOnConflict/];
135

ATTRIBUTE SHORTCUTS

137       "param" and "field" in roles allow the same attribute shortcuts as
138       MooseX::Extended.
139

BUGS AND LIMITATIONS

141       If the MooseX::Extended::Role is loaded via stringy eval, "true" is not
142       loaded, This is because there were intermittant errors (maybe 1 out of
143       5 times) being thrown. Removing this feature under stringy eval solves
144       this. See this github ticket for more infomration
145       <https://github.com/Ovid/moosex-extended/pull/34>.
146

REDUCING BOILERPLATE

148       Let's say you've settled on the following feature set:
149
150           use MooseX::Extended::Role
151               excludes => [qw/WarnOnConflict carp/],
152               includes => [qw/multi/];
153
154       And you keep typing that over and over. We've removed a lot of
155       boilerplate, but we've added different boilerplate. Instead, just
156       create "My::Custom::Moose::Role" and "use My::Custom::Moose::Role;".
157       See MooseX::Extended::Role::Custom for details.
158

AUTHOR

160       Curtis "Ovid" Poe <curtis.poe@gmail.com>
161
163       This software is Copyright (c) 2022 by Curtis "Ovid" Poe.
164
165       This is free software, licensed under:
166
167         The Artistic License 2.0 (GPL Compatible)
168
169
170
171perl v5.38.0                      2023-06-26         MooseX::Extended::Role(3)
Impressum