blib/lib/SQL/Translator/Role/Debug.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 66.6% 4 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 81.6% 40 / 49 CC 5 SCAR 9.9
CC
5
Cov
85%
debug
5.2
__ANON__
3.0
BEGIN
1.0
CRAP 2.7
« blib/lib/SQL/Translator/Role/Error.pm ↑ Summary blib/lib/SQL/Translator/Role/BuildArgs.pm »
1 package SQL::Translator::Role::Debug;
2 71 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 71 ▶use Sub::Quote qw(quote_sub);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 71 has _DEBUG => (
6 is => 'rw',
7 accessor => 'debugging',
8 init_arg => 'debugging',
9 coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
10 lazy => 1,
11 builder => 1,
12 );
13  
14 140 ▶sub _build__DEBUG {
Subroutine _build__DEBUG: called CC=1 SCAR=0.0
15 140 my ($self) = @_;
16 140 my $class = ref $self;
17 71 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 140 return ${"${class}::DEBUG"};
19 }
20  
21 1039 ▶around debugging => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
22 1039 my ($orig, $self) = (shift, shift);
23  
24 # Emulate horrible Class::Base API
25 1039 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 200 839 1039
26 71 ▶ my $dbgref = do { no strict 'refs'; \${"${self}::DEBUG"} };
Subroutine BEGIN: called CC=1 SCAR=0.0
27 200 ▶ $$dbgref = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 200 200
28 200 return $$dbgref;
29 }
30 839 return $self->$orig(@_);
31 71 };
32  
33 919 ▶sub debug {
Subroutine debug: called CC=3 SCAR=16.5
Pod undocumented
34 919 my $self = shift;
35  
36 919 ▶ return unless $self->debugging;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->debugging 919 0 919
37  
38 0 ▶ print STDERR '[', (ref $self || $self), '] ', @_, "\n";
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
39 }
40  
41 71 1;
« blib/lib/SQL/Translator/Role/Error.pm ↑ Summary blib/lib/SQL/Translator/Role/BuildArgs.pm »