.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Role::Commons 3pm" .TH Role::Commons 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Role::Commons \- roles that can be commonly used, for the mutual benefit of all .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use 5.010; \& \& { \& package Local::Class; \& use Moo; \& use Role::Commons \-all; \& our $AUTHORITY = \*(Aqcpan:JOEBLOGGS\*(Aq; \& our $VERSION = \*(Aq1.000\*(Aq; \& } \& \& say Local::Class\->AUTHORITY \& if Local::Class\->DOES(\*(AqRole::Commons::Authority\*(Aq); \& \& my $obj = Local::Class\->new; \& say $obj\->object_id \& if $obj\->DOES(\*(AqRole::Commons::ObjectID\*(Aq); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" 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. .PP The Role::Commons module itself provides shortcuts for applying roles to your package, so that instead of doing: .PP .Vb 2 \& { \& package Local::Class; \& \& use Moo; # or "use Moose" \& with qw( Role::Commons::Authority Role::Commons::ObjectID ); \& } .Ve .PP You can just do this: .PP .Vb 2 \& { \& package Local::Class; \& \& use Moo; \& use Role::Commons qw( Authority ObjectID ); \& } .Ve .PP 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.) .SS Roles .IX Subsection "Roles" .IP Role::Commons::Authority 4 .IX Item "Role::Commons::Authority" Sets up a \f(CW\*(C`AUTHORITY\*(C'\fR method for your class which is conceptually a little like \f(CW\*(C`VERSION\*(C'\fR. .IP Role::Commons::ObjectID 4 .IX Item "Role::Commons::ObjectID" Provides an \f(CW\*(C`object_id\*(C'\fR method for your class which returns a unique identifier for each object. .IP Role::Commons::Tap 4 .IX Item "Role::Commons::Tap" Provides a \f(CW\*(C`tap\*(C'\fR method for your class, inspired by Ruby's method of the same name. Helpful for writing chained method calls. .SS Obsolescence .IX Subsection "Obsolescence" Role-Commons is the successor for my older projects: authority-shared, Object-AUTHORITY, Object-DOES, Object-Role, and Object-Tap. .PP Role-Commons bundles Object::AUTHORITY for the sake of backwards compatibility. This is being phased out. .SH BUGS .IX Header "BUGS" Please report any bugs to . .SH "SEE ALSO" .IX Header "SEE ALSO" Role::Commons::Authority, Role::Commons::ObjectID, Role::Commons::Tap. .PP Role::Tiny, Moo::Role, Moose::Role. .SH AUTHOR .IX Header "AUTHOR" Toby Inkster . .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is copyright (c) 2012, 2014 by Toby Inkster. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. .SH "DISCLAIMER OF WARRANTIES" .IX Header "DISCLAIMER OF WARRANTIES" 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.