Role::Commons(3pm) | User Contributed Perl Documentation | Role::Commons(3pm) |
Role::Commons - roles that can be commonly used, for the mutual benefit of all
use 5.010; { package Local::Class; use Moo; use Role::Commons -all; our $AUTHORITY = 'cpan:JOEBLOGGS'; our $VERSION = '1.000'; } say Local::Class->AUTHORITY if Local::Class->DOES('Role::Commons::Authority'); my $obj = Local::Class->new; say $obj->object_id if $obj->DOES('Role::Commons::ObjectID');
Role-Commons is not yet another implementation of roles. It is a collection of generic, reusable roles that hopefully you will love to apply to your classes. These roles are built using Moo::Role, so automatically integrate into the Moose object system if you're using it, but they do not require Moose.
The Role::Commons module itself provides shortcuts for applying roles to your package, so that instead of doing:
{ package Local::Class; use Moo; # or "use Moose" with qw( Role::Commons::Authority Role::Commons::ObjectID ); }
You can just do this:
{ package Local::Class; use Moo; use Role::Commons qw( Authority ObjectID ); }
It also handles passing some simple parameters through to the role from the consuming class. (Because Moo doesn't have anything like MooseX::Role::Parameterized.)
Role-Commons is the successor for my older projects: authority-shared, Object-AUTHORITY, Object-DOES, Object-Role, and Object-Tap.
Role-Commons bundles Object::AUTHORITY for the sake of backwards compatibility. This is being phased out.
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Role-Commons>.
Role::Commons::Authority, Role::Commons::ObjectID, Role::Commons::Tap.
Role::Tiny, Moo::Role, Moose::Role.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2012, 2014 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.
2021-01-05 | perl v5.32.0 |