Role::Commons(3pm)

Role::Commons3pm

Roles that can be commonly used, for the mutual benefit of all

Usage

 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');

Overview

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.)

Roles

Role::Commons::Authority

Sets up a "AUTHORITY" method for your class which is conceptually a little like "VERSION".

Role::Commons::ObjectID

Provides an "object_id" method for your class which returns a unique identifier for each object.

Role::Commons::Tap

Provides a "tap" method for your class, inspired by Ruby's method of the same name. Helpful for writing chained method calls.

Obsolescence

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.

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.

Releases

6 releases since Debian 8 (Jessie); the text changed 3 times.

  1. 8
  2. 9–10
  3. 11–12
  4. 13

Bugs

Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Role-Commons>.

Author

Toby Inkster <[email protected]>.

From librole-commons-perl 0.104-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.