| 1 |
NAME |
| 2 |
Role::Commons - roles that can be commonly used, for the mutual benefit of |
| 3 |
all |
| 4 |
|
| 5 |
SYNOPSIS |
| 6 |
use 5.010; |
| 7 |
|
| 8 |
{ |
| 9 |
package Local::Class; |
| 10 |
use Moo; |
| 11 |
use Role::Commons -all; |
| 12 |
our $AUTHORITY = 'cpan:JOEBLOGGS'; |
| 13 |
our $VERSION = '1.000'; |
| 14 |
} |
| 15 |
|
| 16 |
say Local::Class->AUTHORITY |
| 17 |
if Local::Class->DOES('Role::Commons::Authority'); |
| 18 |
|
| 19 |
my $obj = Local::Class->new; |
| 20 |
say $obj->object_id |
| 21 |
if $obj->DOES('Role::Commons::ObjectID'); |
| 22 |
|
| 23 |
DESCRIPTION |
| 24 |
Role-Commons is not yet another implementation of roles. It is a |
| 25 |
collection of generic, reusable roles that hopefully you will love to |
| 26 |
apply to your classes. These roles are built using Moo::Role, so |
| 27 |
automatically integrate into the Moose object system if you're using it, |
| 28 |
but they do not require Moose. |
| 29 |
|
| 30 |
The Role::Commons module itself provides shortcuts for applying roles to |
| 31 |
your package, so that instead of doing: |
| 32 |
|
| 33 |
{ |
| 34 |
package Local::Class; |
| 35 |
|
| 36 |
use Moo; # or "use Moose" |
| 37 |
with qw( Role::Commons::Authority Role::Commons::ObjectID ); |
| 38 |
} |
| 39 |
|
| 40 |
You can just do this: |
| 41 |
|
| 42 |
{ |
| 43 |
package Local::Class; |
| 44 |
|
| 45 |
use Moo; |
| 46 |
use Role::Commons qw( Authority ObjectID ); |
| 47 |
} |
| 48 |
|
| 49 |
It also handles passing some simple parameters through to the role from |
| 50 |
the consuming class. (Because Moo doesn't have anything like |
| 51 |
MooseX::Role::Parameterized.) |
| 52 |
|
| 53 |
Roles |
| 54 |
Role::Commons::Authority |
| 55 |
Sets up a `AUTHORITY` method for your class which is conceptually a |
| 56 |
little like `VERSION`. |
| 57 |
|
| 58 |
Role::Commons::ObjectID |
| 59 |
Provides an `object_id` method for your class which returns a unique |
| 60 |
identifier for each object. |
| 61 |
|
| 62 |
Role::Commons::Tap |
| 63 |
Provides a `tap` method for your class, inspired by Ruby's method of |
| 64 |
the same name. Helpful for writing chained method calls. |
| 65 |
|
| 66 |
Obsolescence |
| 67 |
Role-Commons is the successor for my older projects: authority-shared, |
| 68 |
Object-AUTHORITY, Object-DOES, Object-Role, and Object-Tap. |
| 69 |
|
| 70 |
Role-Commons bundles Object::AUTHORITY for the sake of backwards |
| 71 |
compatibility. This is being phased out. |
| 72 |
|
| 73 |
BUGS |
| 74 |
Please report any bugs to |
| 75 |
<http://rt.cpan.org/Dist/Display.html?Queue=Role-Commons>. |
| 76 |
|
| 77 |
SEE ALSO |
| 78 |
Role::Commons::Authority, Role::Commons::ObjectID, Role::Commons::Tap. |
| 79 |
|
| 80 |
Role::Tiny, Moo::Role, Moose::Role. |
| 81 |
|
| 82 |
AUTHOR |
| 83 |
Toby Inkster <[email protected]>. |
| 84 |
|
| 85 |
COPYRIGHT AND LICENCE |
| 86 |
This software is copyright (c) 2012, 2014 by Toby Inkster. |
| 87 |
|
| 88 |
This is free software; you can redistribute it and/or modify it under the |
| 89 |
same terms as the Perl 5 programming language system itself. |
| 90 |
|
| 91 |
DISCLAIMER OF WARRANTIES |
| 92 |
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
| 93 |
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 94 |
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 95 |
|