line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::PluginKit::ConsumerRole; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
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
|
|
23
|
use MooX::PluginKit::Core; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
265
|
|
20
|
3
|
|
|
3
|
|
1146
|
use MooX::PluginKit::Factory; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
107
|
|
21
|
3
|
|
|
3
|
|
22
|
use Types::Standard -types; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
45
|
|
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
12388
|
use Moo::Role; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
19
|
|
24
|
3
|
|
|
3
|
|
1269
|
use strictures 2; |
|
3
|
|
|
|
|
25
|
|
|
3
|
|
|
|
|
108
|
|
25
|
3
|
|
|
3
|
|
544
|
use namespace::clean; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
22
|
|
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
|
83
|
my $self = shift; |
60
|
11
|
|
|
|
|
21
|
my $class = shift; |
61
|
|
|
|
|
|
|
|
62
|
11
|
|
|
|
|
50
|
return $self->plugin_factory->class_new( $class, @_ ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |