Aspect/Advice.pm

filter: Statementstmt 86.6% 26 / 30 Branchbran 66.6% 4 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 8 / 10 Podpod 0.0% 0 / 2 totaltotal 71.7% 38 / 53 SCAR 16.7
CC
5
Cov
77%
_install
6.0
_validate
2.1
new
2.0
CRAP 5.3
« Aspect/Pointcut/Cflow.pm ↑ Summary Aspect/Modular.pm »
1 package Aspect::Advice;
2  
3 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 21 our $VERSION = '0.97_06';
8  
9 sub new {
10 115 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
11 115 my $self = bless {
12 @_,
13 installed => 0,
14 }, $class;
15  
16 # Validate the advice and pointcut combination
17 115 my $error = $self->_validate;
18 115 ▶ Carp::croak($error) if defined $error;
Branch: 1 branch
BranchTrueFalseTotal
if defined $error 0 115 115
19  
20 # Install and save the lexical hook
21 115 $self->{hook} = $self->_install;
22  
23 115 return $self;
24 }
25  
26 sub code {
27 $_[0]->{code};
28 }
29  
30 sub pointcut {
31 $_[0]->{pointcut};
32 }
33  
34 sub lexical {
35 $_[0]->{lexical};
36 }
37  
38 sub installed {
39 0 ▶ $_[0]->{installed};
Subroutine installed: not called CC=1 SCAR=6.9
Pod undocumented
40 }
41  
42 sub DESTROY {
43 115 ▶ $_[0]->{hook}->() if $_[0]->{hook};
Subroutine DESTROY: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"hook"} 71 44 115
44 }
45  
46  
47  
48  
49  
50 ######################################################################
51 # Installation Internals
52  
53 sub _install {
54 0 ▶ my $class = ref $_[0] || $_[0];
Subroutine _install: not called CC=2 SCAR=17.9
Condition0%0/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
55 0 die("Method '_install' is not implemented by class '$class'");
56 }
57  
58 sub _validate {
59 115 ▶ my $self = shift;
Subroutine _validate: called CC=2 SCAR=7.6
60  
61 # The use of more than one highest rule in a pointcut is not supported
62 115 ▶ if ( $self->pointcut->match_contains('Aspect::Pointcut::Highest') > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->pointcut->match_contains("Aspect::Pointcut::Highest") > 1) 0 115 115
63 0 return "Multiple highest pointcut use is not yet supported";
64 }
65  
66 115 return;
67 }
68  
69  
70  
71  
72  
73 ######################################################################
74 # Optional XS Acceleration
75  
76 BEGIN {
77 21 ▶ local $@;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 21 ▶ eval <<'END_PERL';
Subroutine BEGIN: called CC=1 SCAR=0.0
79 use Class::XSAccessor 1.08 {
80 replace => 1,
81 getters => {
82 'code' => 'code',
83 'pointcut' => 'pointcut',
84 'lexical' => 'lexical',
85 },
86 };
87 END_PERL
88 }
89  
90 21 1;
91  
92 __END__
« Aspect/Pointcut/Cflow.pm ↑ Summary Aspect/Modular.pm »