-
-
14 Jul 2020 17:47:51 UTC
- Distribution: With-Roles
- Module version: 0.001002
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues
- Testers (329 / 0 / 0)
- Kwalitee
Bus factor: 1- 75.00% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (13.26KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
With::Roles - Create role/class/object with composed roles
SYNOPSIS
use With::Roles; # create class inheriting from My::Class, with My::Role applied my $class = My::Class->with::roles('My::Role'); # create a role with My::Role, then Another::Role applied my $role = My::Role->with::roles('Another::Role'); # generated role can be applied my $obj = My::Class->with::roles($role)->new; # apply role to object $obj->with::roles('Yet::Another::Role'); # applies the role My::Class::Role::My::Role my $another_class = My::Class->with::roles('+My::Role');
DESCRIPTION
This module provides an easy to use global function that can be used on any package to create a new package with a set of roles applied.
When used on classes, generates a subclass with the given roles applied.
When used on roles, generates a new role with the base and given roles applied.
When used on objects, applies the roles to the object and returns the object. Unlike with roles and classes, this modifies the invocant.
Compatible with Moose, Moo, Mouse, and Role::Tiny roles and classes.
The generated packages will have names based on the original classes and roles to aid with debugging. The exact form of the generated names should not be relied on.
A shorthand of
+RoleName
can be used for roles named likeMyClass::Role::RoleName
. Additional roles applied will continue to base the name on the original class. The package can also provide a methodROLE_BASE
to return a prefix to use other thanMyClass::Role
.ROLE_BASE
support is experimental, and may be removed or changed in a future version.AUTHOR
haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>
CONTRIBUTORS
None so far.
COPYRIGHT
Copyright (c) 2019 the With::Roles "AUTHOR" and "CONTRIBUTORS" as listed above.
LICENSE
This library is free software and may be distributed under the same terms as perl itself. See https://dev.perl.org/licenses/.
Module Install Instructions
To install With::Roles, copy and paste the appropriate command in to your terminal.
cpanm With::Roles
perl -MCPAN -e shell install With::Roles
For more information on module installation, please visit the detailed CPAN module installation guide.