blib/lib/Class/Implant.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 98.0% 51 / 52 CC 7 SCAR 13.4
CC
7
Cov
100%
implant
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.8
↑ Summary
1 package Class::Implant;
2 # ABSTRACT: Manipulating mixin and inheritance out of packages
3  
4 4 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Class::Inspector;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = '0.01';
11  
12 4 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
13 4 *{(caller)[0] . "::implant"} = \&implant;
14 }
15  
16 3 ▶sub implant (@) {
Subroutine implant: called CC=7 SCAR=19.5
Pod undocumented
17 3 ▶ my $option = ( ref($_[-1]) eq "HASH" ? pop(@_) : undef );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 2 1 3
18 3 my @class = @_;
19  
20 3 my $target = caller;
21  
22 3 ▶ if (defined($option)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option) 2 1 3
23 2 ▶ $target = $option->{into} if defined($option->{into});
Branch: 1 branch
BranchTrueFalseTotal
if defined $option->{"into"} 1 1 2
24 2 ▶ eval qq{ package $target; use base qw(@class); } if $option->{inherit};
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $option->{"inherit"} 1 1 2
25 }
26  
27 3 for my $class (reverse @class) {
28 3 for my $function (@{ _get_methods($class) }) {
29 6 *{ $target . "::" . $function } = \&{ $class . "::" . $function };
30 }
31 }
32  
33 }
34  
35 3 ▶sub _get_methods { Class::Inspector->functions(shift) }
Subroutine _get_methods: called CC=1 SCAR=0.0
36  
37 4 1;
38  
39  
40 __END__
↑ Summary