1MooseX::Role::ParameterUiszeerd:C:oEnxttreinbduitnegdM(o3Po)esrelX:D:oRcoulmee:n:tPaatriaomneterized::Extending(3)
2
3
4

NAME

6       MooseX::Role::Parameterized::Extending - extending
7       MooseX::Role::Parameterized roles
8

VERSION

10       version 1.10
11

DESCRIPTION

13       There are heaps of useful modules in the "MooseX" namespace that you
14       can use to make your roles more powerful. However, they do not always
15       work out of the box with MooseX::Role::Parameterized, but it's fairly
16       straight-forward to achieve the functionality you desire.
17
18       MooseX::Role::Parameterized was designed to be as extensible as the
19       rest of Moose, and as such it is possible to apply custom traits to
20       both the parameterizable role or the ordinary roles they generate. In
21       this example, we will look at applying the fake trait
22       "MooseX::MagicRole" to a parameterizable role.
23
24       First we need to define a new metaclass for our parameterizable role.
25
26           package MyApp::Meta::Role::Parameterizable;
27           use Moose;
28           extends 'MooseX::Role::Parameterized::Meta::Role::Parameterizable';
29           with 'MooseX::MagicRole';
30
31       This is a class (observe that it uses Moose, not Moose::Role) which
32       extends the class which governs parameterizable roles.
33       MooseX::Role::Parameterized::Meta::Role::Parameterizable is the
34       metaclass that packages using MooseX::Role::Parameterized receive by
35       default.
36
37       Note that the class we are extending,
38       MooseX::Role::Parameterized::Meta::Role::Parameterizable, is entirely
39       distinct from the similarly-named class which governs the ordinary
40       roles that parameterized roles generate. An instance of
41       MooseX::Role::Parameterized::Meta::Role::Parameterized represents a
42       role with its parameters already bound.
43
44       Now we can take advantage of our new subclass by specifying that we
45       want to use "MyApp::Meta::Role::Parameterizable" as our metaclass when
46       importing MooseX::Role::Parameterized:
47
48           package MyApp::Role;
49           use MooseX::Role::Parameterized -metaclass => 'MyApp::Meta::Role::Parameterizable';
50
51           role {
52               ...
53           }
54
55       And there you go! "MyApp::Role" now has the "MooseX::MagicRole" trait
56       applied.
57

NAME

SUPPORT

60       Bugs may be submitted through the RT bug tracker
61       <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Role-
62       Parameterized> (or bug-MooseX-Role-Parameterized@rt.cpan.org
63       <mailto:bug-MooseX-Role-Parameterized@rt.cpan.org>).
64
65       There is also a mailing list available for users of this distribution,
66       at <http://lists.perl.org/list/moose.html>.
67
68       There is also an irc channel available for users of this distribution,
69       at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
70

AUTHOR

72       Shawn M Moore <code@sartak.org>
73
75       This software is copyright (c) 2008 by Shawn M Moore.
76
77       This is free software; you can redistribute it and/or modify it under
78       the same terms as the Perl 5 programming language system itself.
79
80
81
82perl v5.28.1                      2017M-o0o4s-e2X0::Role::Parameterized::Extending(3)
Impressum