blib/lib/Apache/Singleton/Process.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 79.4% 31 / 39 CC 3 SCAR 4.1
CC
3
Cov
86%
_get_instance
2.1
_set_instance
2.1
BEGIN
1.0
CRAP 1.5
« blib/lib/Apache/Singleton.pm ↑ Summary lib/Apache/Singleton/Request.pm »
1 #
2 # This file is part of Apache-Singleton
3 #
4 # This software is copyright (c) 2009 by Michael Schout.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9  
10 package Apache::Singleton::Process;
11 7 $Apache::Singleton::Process::VERSION = '0.17';
12 # ABSTRACT: One instance per One Process
13  
14 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 7 ▶use base 'Apache::Singleton';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 7 ▶no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 7 my %INSTANCES;
22  
23 14 ▶sub _get_instance {
Subroutine _get_instance: called CC=2 SCAR=7.6
24 14 my $class = shift;
25  
26 14 ▶ $class = ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0140
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
27  
28 14 return $INSTANCES{$class};
29 }
30  
31 6 ▶sub _set_instance {
Subroutine _set_instance: called CC=2 SCAR=7.6
32 6 my($class, $instance) = @_;
33  
34 6 ▶ $class = ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
060
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
35  
36 6 $INSTANCES{$class} = $instance;
37 }
38  
39 7 ▶END {
Subroutine END: called CC=1 SCAR=0.0
40 # dereferences and causes orderly destruction of all instances
41 7 undef(%INSTANCES);
42 }
43  
44 7 1;
45  
46 __END__
« blib/lib/Apache/Singleton.pm ↑ Summary lib/Apache/Singleton/Request.pm »