blib/lib/Tie/Discovery.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 2 / 2 totaltotal 91.8% 56 / 61 CC 5 SCAR 6.4
CC
5
Cov
91%
FETCH
4.1
STORE
2.0
register
2.0
CRAP 1.9
↑ Summary
1 package Tie::Discovery;
2  
3 1 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use vars qw( $VERSION @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 $VERSION = '1.11';
8 1 @ISA = 'Tie::StdHash';
9  
10 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Tie::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use constant SELF => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use constant KEY => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use constant VALUE => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶sub TIEHASH {
Subroutine TIEHASH: called CC=1 SCAR=0.0
17 1 return bless { debug => 0 }, shift;
18 }
19  
20 0 ▶sub STORE {
Subroutine STORE: not called CC=1 SCAR=6.9
21 0 carp "Please don't do this. Use \$obj->store or \$obj->register instead.";
22 0 store(@_);
23 }
24  
25 2 ▶sub store { # ($$$)
Subroutine store: called CC=1 SCAR=0.0
Pod documented
26 2 $_[SELF]{ $_[KEY] } = $_[VALUE];
27 }
28  
29 7 ▶sub register { # ($$\&)
Subroutine register: called CC=2 SCAR=6.9
Pod documented
30 7 ▶ UNIVERSAL::isa($_[VALUE] => 'CODE')
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[2], "CODE") or croak("Second argument to register() should be coderef") 6 1 7
31 or croak "Second argument to register() should be coderef";
32 6 $_[SELF]{ $_[KEY] } = $_[VALUE];
33 }
34  
35 11 ▶sub FETCH {
Subroutine FETCH: called CC=4 SCAR=14.0
36 11 my $value = $_[SELF]{ $_[KEY] };
37 11 ▶ while (UNIVERSAL::isa($value, 'CODE')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, "CODE")) 8 11 19
38 8 ▶ print STDERR "(Discovering $_[KEY]... " if $_[SELF]{debug} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"debug"} > 0 0 8 8
39 8 $value = $_[SELF]{ $_[KEY] } = $value->(@_);
40 8 ▶ print STDERR ")" if $_[SELF]->{debug} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"debug"} > 0 0 8 8
41 }
42 11 return $value;
43 }
44  
45 1 1;
46 __END__
↑ Summary