1MooseX::Role::ParameterUiszeerd:C:oEnxttreinbduitnegdM(o3Po)esrelX:D:oRcoulmee:n:tPaatriaomneterized::Extending(3)
2
3
4
6 MooseX::Role::Parameterized::Extending - extending
7 MooseX::Role::Parameterized roles
8
10 There are heaps of useful modules in the MooseX namespace that you can
11 use to make your roles more powerful. However, they do not always work
12 out of the box with MooseX::Role::Parameterized, but it's
13 fairlystraight forward to achieve the functionality you desire.
14
15 MooseX::Role::Parameterized was designed to be extensible, and it is
16 now possible to apply custom traits to the generated role, giving them
17 the functionality provided in MooseX modules. In this example, we will
18 look at applying the fake trait 'MooseX::MagicRole' to a parameterized
19 role.
20
21 The first we need to do is define a new metaclass for our parameterized
22 role. To get MooseX::Role::Parameterized to apply this metaclass to
23 our roles, we need a little bit of glue first:
24
25 package MyApp::Meta::Role::Parameterizable;
26 use Moose;
27 extends 'MooseX::Role::Parameterized::Meta::Role::Parameterizable';
28 sub parameterized_role_metaclass { 'MyApp::Meta::Role::Parameterized' }
29
30 Now we can take advantage of this by specifying our glue metaclass to
31 MooseX::Role::Parameterized:
32
33 package MyApp::Role;
34 use MooseX::Role::Parameterized -metaclass => 'MyApp::Meta::Role::Parameterizable';
35
36 role {
37 }
38
39 And there you go! MyApp::Role now has the MooseX::MagicRole trait
40 applied.
41
42
43
44perl v5.12.0 2010M-o0o1s-e1X7::Role::Parameterized::Extending(3)