line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::PluginKit::ConsumerRole; |
2
|
3
|
|
|
3
|
|
61
|
use 5.008001; |
|
3
|
|
|
|
|
9
|
|
3
|
3
|
|
|
3
|
|
18
|
use strictures 2; |
|
3
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
124
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
MooX::PluginKit::ConsumerRole - Common functionality for PluginKit consumers. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head2 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This role alters C to replace the C argument with the |
13
|
|
|
|
|
|
|
L argument. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Using this role by itself isn't all that useful. Instead head on over to |
16
|
|
|
|
|
|
|
L. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
3
|
|
709
|
use MooX::PluginKit::Core; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
283
|
|
21
|
3
|
|
|
3
|
|
1081
|
use MooX::PluginKit::Factory; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
143
|
|
22
|
3
|
|
|
3
|
|
27
|
use Types::Standard -types; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
30
|
|
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
|
12334
|
use Moo::Role; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
24
|
|
25
|
3
|
|
|
3
|
|
1428
|
use namespace::clean; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
25
|
|
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
|
88
|
my $self = shift; |
60
|
11
|
|
|
|
|
18
|
my $class = shift; |
61
|
|
|
|
|
|
|
|
62
|
11
|
|
|
|
|
47
|
return $self->plugin_factory->class_new( $class, @_ ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |