Cache/Component.pm

filter: Statementstmt 100% 44 / 44 Branchbran 75.0% 6 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 90.5% 67 / 74 CC 7 SCAR 9.0
CC
7
Cov
93%
cache
5.1
cache_memoized
3.0
BEGIN
1.0
CRAP 2.5
↑ Summary Cache/Filters.pm »
1 package Mason::Plugin::Cache::Component;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Mason::Plugin::Cache::Component::VERSION = '0.05';
4 }
5 1 ▶use Mason::PluginRole;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 my %memoized;
8  
9 1 ▶method cache_memoized ($class:) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine cache_memoized: called CC=3 SCAR=11.0
10 34 ▶ $class = ref($class) || $class;
Condition66%2/3
ref $class || $class
l!l&&r!l&&!r
3040
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table66%2/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
11 34 ▶ if (@_) { $memoized{$class} = $_[0] }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 5 29 34
12 34 return $memoized{$class};
13 1 }
14  
15 1 ▶method cache_defaults ($class:) { $class->cmeta->interp->cache_defaults }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine cache_defaults: called CC=1 SCAR=0.0
16 1 ▶method cache_root_class ($class:) { $class->cmeta->interp->cache_root_class }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
17 1 ▶method cache_namespace ($class:) { $class->cmeta->path }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine cache_namespace: called CC=1 SCAR=0.0
18  
19 1 ▶method cache ($class:) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine cache: called CC=5 SCAR=16.2
20 15 ▶ if ( !@_ && $class->cache_memoized ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @_ and $class->cache_memoized) 11 4 15
Condition66%2/3
not @_ and $class->cache_memoized
!ll&&!rl&&r
0411
MC/DC50%1/2
not @_ and $class->cache_memoized
not @_ $class->cache_memoized
Truth table66%2/3
not(A) and B
A= not @_B= $class->cache_memoized
ABresult
0X0
100
111
21 11 return $class->cache_memoized;
22 }
23 4 my $cache_root_class = $class->cache_root_class;
24 4 my %options = ( %{ $class->cache_defaults }, @_ );
25 4 ▶ if ( !exists( $options{namespace} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $options{"namespace"}) 4 0 4
26 4 $options{namespace} = $class->cache_namespace;
27 }
28 4 my $cache = $cache_root_class->new(%options);
29 4 ▶ if ( !@_ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 4 0 4
30 4 $class->cache_memoized($cache);
31 }
32 4 return $cache;
33 1 }
34  
35 1 1;
↑ Summary Cache/Filters.pm »