blib/lib/MooseX/AccessorsOnly.pm

filter: Statementstmt 58.9% 23 / 39 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 55.5% 5 / 9 Podpod n/a totaltotal 42.4% 28 / 66 CC 8 SCAR 27.0
CC
8
Cov
43%
TIEHASH
30.0
__ANON__
20.0
DESTROY
2.0
CRAP 14.9
↑ Summary
1 package MooseX::AccessorsOnly;
2  
3 1 our $VERSION = '1';
4 1 $VERSION = eval $VERSION;
5  
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Tie::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 our @ISA = 'Tie::StdHash';
11  
12 1 our %magic; # Global on the off chance somebody wants to fuck with it
13  
14 0 ▶sub TIEHASH {
Subroutine TIEHASH: not called CC=5 SCAR=34.0
15 0 my $self = shift;
16 0 my $store = $self->SUPER::TIEHASH();
17 0 ▶ if (ref $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 0 0 0
18 0 $magic{"$store"}{cb} = $_[0];
19 } else {
20 0 ▶ my $complainer = $_[0] || 'carp';
Condition0%0/2
$_[0] || 'carp'
l!l
00
MC/DC0%0/1
$_[0] || 'carp'
$_[0]
Truth table0%0/2
A
A= $_[0]
Aresult
11
00
21 Carp::croak "Invalid complainer $complainer"
22 0 ▶ unless grep { $complainer eq $_ }
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$complainer eq $_;} "carp", "croak", "confess", "cluck", "die", "warn" 0 0 0
23 qw(carp croak confess cluck die warn);
24 0 ▶ $complainer = 'Carp::' . $complainer if $complainer =~ /^c/; # convenient
Branch: 1 branch
BranchTrueFalseTotal
if $complainer =~ /^c/ 0 0 0
25 # Eugh:
26 0 $magic{"$store"}{cb} = eval qq{
27 sub {
28 my (\$who, \$how, \$what) = \@_;
29 $complainer ("DIRECT ACCESS from \$who: \$how " . \$what || 'NOKEY');
30 }
31 };
32 }
33 0 $store;
34 }
35  
36 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=6.9
37 0 delete $magic{"$_[0]"};
38 # Tie::StdHash doesn't have a DESTROY method
39 }
40  
41 0 ▶sub UNTIE { Carp::croak "Attempt to UNTIE" }
Subroutine UNTIE: not called CC=1 SCAR=6.9
42  
43 1 for my $sub (qw(
44 CLEAR
45 DELETE
46 EXISTS
47 FETCH
48 FIRSTKEY
49 NEXTKEY
50 SCALAR
51 STORE
52 )) {
53 8 my $super = 'SUPER::' . $sub;
54 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
55 0 ▶ *$sub = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
56 0 my $self = shift;
57 0 my @caller = caller(0);
58 0 ▶ $magic{"$self"}{cb}->("$caller[0]:$caller[2]", $sub, $_[0])
Branch: 1 branch
BranchTrueFalseTotal
unless 0 0 0
Condition0%0/5
or $caller[0] =~ /^(?:Eval::Closure|Data::Dump)/
l!l&&r!l&&!r
000
(caller 2)[0] or
l!l
00
MC/DC0%0/2
or $caller[0] =~ /^(?:Eval::Closure|Data::Dump)/
(caller 2)[0] $caller[0] =~ /^(?:Eval::Closure|Data::Dump)/
Truth table0%0/3
A or B
A= (caller 2)[0]B= $caller[0] =~ /^(?:Eval::Closure|Data::Dump)/
ABresult
1X1
011
000
59 unless (caller(2))[0] || '' eq 'Moose::Object'
60 or $caller[0] =~ /^(?:Eval::Closure|Data::Dump)/;
61 0 $self->$super(@_);
62 8 };
63 }
64  
65 1 1;
66  
67 __END__
↑ Summary