Roles with composition parameters
Your parameterized role consists of two new things: parameter declarations
and a 'role' block.
Parameters are declared using the the /parameter manpage keyword which very
much resembles the Moose/has manpage. You can use any option that the
Moose/has manpage accepts. The default value for the 'is' option is 'ro' as
that's a very common case. Use 'is => 'bare'' if you want no accessor.
These parameters will get their values when the consuming class (or role)
uses the Moose/with manpage. A parameter object will be constructed with
these values, and passed to the 'role' block.
The 'role' block then uses the usual the Moose::Role manpage keywords to
build up a role. You can shift off the parameter object to inspect what the
consuming class provided as parameters. You use the parameters to customize
your role however you wish.
There are many possible implementations for parameterized roles (hopefully
with a consistent enough API); I believe this to be the easiest and most
flexible design. Coincidentally, Pugs originally had an eerily similar
design.
See the MooseX::Role::Parameterized::Extending manpage for some tips on how
to extend this module.
- Sources inherited from project openSUSE:Leap:42.2
- Download package
-
Checkout Package
osc -A https://api.opensuse.org checkout openSUSE:Leap:42.2:Ports/perl-MooseX-Role-Parameterized && cd $_
- Create Badge
Source Files
Filename | Size | Changed |
---|---|---|
MooseX-Role-Parameterized-1.08.tar.gz | 0000043284 42.3 KB | |
cpanspec.yml | 0000000480 480 Bytes | |
perl-MooseX-Role-Parameterized.changes | 0000003699 3.61 KB | |
perl-MooseX-Role-Parameterized.spec | 0000003900 3.81 KB |
Latest Revision
vrev freeze
Comments 0