line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::PluginKit::ConsumerRole; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$MooX::PluginKit::ConsumerRole::VERSION = '0.04'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
MooX::PluginKit::ConsumerRole - Common functionality for PluginKit consumers. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head2 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This role alters C to replace the C argument with the |
12
|
|
|
|
|
|
|
L argument. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Using this role by itself isn't all that useful. Instead head on over to |
15
|
|
|
|
|
|
|
L. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
19
|
use MooX::PluginKit::Core; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
260
|
|
20
|
3
|
|
|
3
|
|
1068
|
use MooX::PluginKit::Factory; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
103
|
|
21
|
3
|
|
|
3
|
|
25
|
use Types::Standard -types; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
29
|
|
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
11407
|
use Moo::Role; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
21
|
|
24
|
3
|
|
|
3
|
|
1280
|
use strictures 2; |
|
3
|
|
|
|
|
37
|
|
|
3
|
|
|
|
|
113
|
|
25
|
3
|
|
|
3
|
|
544
|
use namespace::clean; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
20
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
around BUILDARGS => sub{ |
28
|
|
|
|
|
|
|
my $orig = shift; |
29
|
|
|
|
|
|
|
my $class = shift; |
30
|
|
|
|
|
|
|
my $args = $class->$orig( @_ ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $factory = MooX::PluginKit::Factory->new( |
33
|
|
|
|
|
|
|
plugins => delete( $args->{plugins} ) || [], |
34
|
|
|
|
|
|
|
namespace => get_consumer_namespace( $class ), |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$args->{plugin_factory} = $factory; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $args; |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 ARGUMENTS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 plugin_factory |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The L used to apply plugins to a class. |
47
|
|
|
|
|
|
|
There shouldn't be a reason to set this argument directly. Instead |
48
|
|
|
|
|
|
|
you'll want to set the C argument which gets pseudo-coerced |
49
|
|
|
|
|
|
|
into this argument. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has plugin_factory => ( |
54
|
|
|
|
|
|
|
is => 'ro', |
55
|
|
|
|
|
|
|
isa => InstanceOf[ 'MooX::PluginKit::Factory' ], |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub class_new_with_plugins { |
59
|
11
|
|
|
11
|
0
|
81
|
my $self = shift; |
60
|
11
|
|
|
|
|
20
|
my $class = shift; |
61
|
|
|
|
|
|
|
|
62
|
11
|
|
|
|
|
48
|
return $self->plugin_factory->class_new( $class, @_ ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |