Role::Commons(3pm)

πŸ“¦
version 0.104 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– Role::Commons πŸ’–

okay so bestie, welcome to Role::Commons β€” the Perl module (that's the 3pm bit, iykyk) that's literally just roles you can slap onto your classes for the mutual benefit of everyone. πŸ‘‘


✨ NAME ✨

Role::Commons β€” roles that can be commonly used, for the mutual benefit of all. 🫢


🌸 SYNOPSIS 🌸

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

like... look at that. -all and suddenly your class is serving. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Role-Commons is not yet another implementation of roles, ok?? it is not that. what it actually 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 they automatically integrate into the Moose object system if you're using it, but bestie β€” they do not require Moose. no cap.

the Role::Commons module itself provides shortcuts for applying roles to your package, so that instead of doing this whole entire thing:

{
  package Local::Class;

  use Moo;  # or "use Moose"
  with qw( Role::Commons::Authority Role::Commons::ObjectID );
}

you can just do this, which is so much cuter:

{
  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 β€” rip πŸ™ˆ)

⭐ Roles ⭐

  • Role::Commons::Authority β€” sets up a AUTHORITY method for your class, which is conceptually a little like VERSION. iconic behavior honestly.
  • Role::Commons::ObjectID β€” provides an object_id method for your class which returns a unique identifier for each object. every object gets its own little name tag πŸŽ€
  • Role::Commons::Tap β€” provides a tap method for your class, inspired by Ruby's method of the same name. super 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. rest in peace to the OGs πŸ•―οΈ

Role-Commons bundles Object::AUTHORITY for the sake of backwards compatibility. this is being phased out. ⚠️ like, don't build your whole personality around it, it's on the way out.


😭 BUGS 😭

please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Role-Commons>. bestie if something's broken, tell me, don't just suffer in silence 🫢


πŸ‘€ SEE ALSO πŸ‘€

Role::Commons::Authority, Role::Commons::ObjectID, Role::Commons::Tap.

Role::Tiny, Moo::Role, Moose::Role.


πŸ’œ AUTHOR πŸ’œ

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. slay. πŸ’…


πŸ”₯ 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.

(there's no warranty bestie, we've been over this 😭)


and that's the whole page!! this one came from perl v5.32.0, dated 2021-01-05, and it's the manual for Role::Commons(3pm) β€” mwah, go forth and apply some roles πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from