PluginKit/ConsumerRole.pm

filter: Statementstmt 100% 33 / 33 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 97.8% 45 / 46 CC 2 SCAR 1.8
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« PluginKit/ConsumerBase.pm ↑ Summary PluginKit/Plugin.pm »
1 package MooX::PluginKit::ConsumerRole;
2 3 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 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<BUILDARGS> to replace the C<plugins> argument with the
13 L</plugin_factory> argument.
14  
15 Using this role by itself isn't all that useful. Instead head on over to
16 L<MooX::PluginKit::Consumer>.
17  
18 =cut
19  
20 3 ▶use MooX::PluginKit::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶use MooX::PluginKit::Factory;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 3 ▶use Types::Standard -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 3 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 36 ▶around BUILDARGS => sub{
Subroutine __ANON__: called CC=2 SCAR=6.9
28 36 my $orig = shift;
29 36 my $class = shift;
30 36 my $args = $class->$orig( @_ );
31  
32 my $factory = MooX::PluginKit::Factory->new(
33 36 ▶ plugins => delete( $args->{plugins} ) || [],
Condition100%2/2
delete $args->{'plugins'} || []
l!l
2016
MC/DC100%1/1
delete $args->{'plugins'} || []
delete $args->{'plugins'}
Truth table100%2/2
A
A= delete $args->{'plugins'}
Aresult
11
00
34 namespace => get_consumer_namespace( $class ),
35 );
36  
37 36 $args->{plugin_factory} = $factory;
38  
39 36 return $args;
40 3 };
41  
42 =head1 ARGUMENTS
43  
44 =head2 plugin_factory
45  
46 The L<MooX::PluginKit::Factory> 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<plugins> argument which gets pseudo-coerced
49 into this argument.
50  
51 =cut
52  
53 3 has plugin_factory => (
54 is => 'ro',
55 isa => InstanceOf[ 'MooX::PluginKit::Factory' ],
56 );
57  
58 11 ▶sub class_new_with_plugins {
Subroutine class_new_with_plugins: called CC=1 SCAR=0.0
Pod undocumented
59 11 my $self = shift;
60 11 my $class = shift;
61  
62 11 return $self->plugin_factory->class_new( $class, @_ );
63 }
64  
65 3 1;
66 __END__
« PluginKit/ConsumerBase.pm ↑ Summary PluginKit/Plugin.pm »