blib/lib/Apache/Singleton.pm

filter: Statementstmt 86.2% 25 / 29 Branchbran 60.0% 6 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 76.4% 39 / 51 CC 6 SCAR 8.0
CC
6
Cov
79%
_new_instance
3.3
_get_instance
2.1
_set_instance
2.1
CRAP 2.2
↑ Summary blib/lib/Apache/Singleton/Process.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;
11 7 $Apache::Singleton::VERSION = '0.17';
12 # ABSTRACT: Singleton class for mod_perl
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 # load appropriate subclass
18 7 ▶if ($ENV{MOD_PERL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'MOD_PERL'}) { } 0 7 7
19 0 require Apache::Singleton::Request;
20 }
21 else {
22 7 require Apache::Singleton::Process;
23 }
24  
25 22 ▶sub instance {
Subroutine instance: called CC=2 SCAR=6.9
Pod undocumented
26 22 my $class = shift;
27  
28 22 my $instance = $class->_get_instance;
29 22 ▶ unless (defined $instance) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $instance) 10 12 22
30 10 $instance = $class->_new_instance(@_);
31 10 $class->_set_instance($instance);
32 }
33 22 return $instance;
34 }
35  
36 10 ▶sub _new_instance {
Subroutine _new_instance: called CC=3 SCAR=12.0
37 10 my $class = shift;
38  
39 0 ▶ my %args = (@_ && ref $_[0] eq 'HASH') ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ && ref $_[0] eq 'HASH' ? : 0 10 10
Condition66%2/3
@_ and ref $_[0] eq "HASH"
!ll&&!rl&&r
910
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_ ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
40  
41 10 bless { %args }, $class;
42 }
43  
44 # Abstract methods, but compatible default
45 10 ▶sub _get_instance {
Subroutine _get_instance: called CC=2 SCAR=7.6
46 10 my $class = shift;
47  
48 10 ▶ if ($ENV{MOD_PERL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'MOD_PERL'}) { } 0 10 10
49 0 $class->Apache::Singleton::Request::_get_instance(@_);
50 }
51 else {
52 10 $class->Apache::Singleton::Process::_get_instance(@_);
53 }
54 }
55  
56 4 ▶sub _set_instance {
Subroutine _set_instance: called CC=2 SCAR=7.6
57 4 my $class = shift;
58  
59 4 ▶ if ($ENV{MOD_PERL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'MOD_PERL'}) { } 0 4 4
60 0 $class->Apache::Singleton::Request::_set_instance(@_);
61 }
62 else {
63 4 $class->Apache::Singleton::Process::_set_instance(@_);
64 }
65 }
66  
67 7 1;
68  
69 __END__
↑ Summary blib/lib/Apache/Singleton/Process.pm »