MooseX::Extended::Role - MooseX::Extended roles
version 0.03
package Not::Corinna::Role::Created { use MooseX::Extended::Role; use MooseX::Extended::Types qw(PositiveInt); field created => ( isa => PositiveInt, default => sub { time } ); }
Similar to MooseX::Extended, this provides field and param to the role.
field
param
Note that there is no need to add a 1 at the end of the role.
1
In Moose if a class defines a method of the name as the method of a role it's consuming, the role's method is silently discarded. With MooseX::Extended::Role, you get a warning. This makes maintenance easier when to prevent you from accidentally overriding a method.
For example:
package My::Role { use MooseX::Extended::Role; sub name {'Ovid'} } package My::Class { use MooseX::Extended; with 'My::Role'; sub name {'Bob'} }
The above code will still run, but you'll get a very verbose warning:
The class My::Class has implicitly overridden the method (name) from role My::Role. If this is intentional, please exclude the method from composition to silence this warning (see Moose::Cookbook::Roles::Recipe2)
To silence the warning, just be explicit about your intent:
package My::Class { use MooseX::Extended; with 'My::Role' => { -excludes => ['name'] }; sub name {'Bob'} }
Curtis "Ovid" Poe <curtis.poe@gmail.com>
This software is Copyright (c) 2022 by Curtis "Ovid" Poe.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install MooseX::Extended, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Extended
CPAN shell
perl -MCPAN -e shell install MooseX::Extended
For more information on module installation, please visit the detailed CPAN module installation guide.