Lazy/Session/Data.pm

filter: Statementstmt 24.1% 7 / 29 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 33.3% 2 / 6 Podpod 0.0% 0 / 3 totaltotal 15.7% 9 / 57 CC 9 SCAR 40.7
CC
9
Cov
15%
AUTOLOAD
90.0
q
2.0
session
2.0
CRAP 58.4
« Lazy/Widget.pm ↑ Summary Lazy/Template/Boilerplate.pm »
1 package CGI::Lazy::Session::Data;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use CGI::Lazy::Globals;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 #----------------------------------------------------------------------------------------------
8 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=9 SCAR=45.0
9 0 my $self = shift;
10  
11 0 my $name = our $AUTOLOAD;
12 0 ▶ return if $name =~ /::DESTROY$/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /::DESTROY$/ 0 0 0
13 0 my @list = split "::", $name;
14 0 my $value = pop @list;
15 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
16 0 $self->{_data}->{$value} = shift; #this will work equally well for scalars and array refs. Do we need it to fly for lists?
17 0 ▶ $self->session->save unless ($self->q->plugin->session->{autowrite} && ($self->q->plugin->session->{autowrite} == 0));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->q->plugin->session->{"autowrite"} and $self->q->plugin->session->{"autowrite"} == 0 0 0 0
Condition0%0/3
$self->q->plugin->session->{"autowrite"} and $self->q->plugin->session->{"autowrite"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->q->plugin->session->{"autowrite"} and $self->q->plugin->session->{"autowrite"} == 0
$self->q->plugin->session->{"autowrite"} $self->q->plugin->session->{"autowrite"} == 0
Truth table0%0/3
A and B
A= $self->q->plugin->session->{"autowrite"}B= $self->q->plugin->session->{"autowrite"} == 0
ABresult
0X0
100
111
18 } else {
19 0 ▶ if (ref $self->{_data}->{$value} eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self->{'_data'}{$value} eq 'HASH') { } 0 0 0
elsif (ref $self->{'_data'}{$value} eq 'ARRAY') { } 0 0 0
20 0 ▶ return wantarray ? %{$self->{_data}->{$value}} : $self->{_data}->{$value};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
21 } elsif (ref $self->{_data}->{$value} eq 'ARRAY') {
22 0 ▶ return wantarray ? @{$self->{_data}->{$value}} : $self->{_data}->{$value};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
23 } else {
24 0 return $self->{_data}->{$value};
25 }
26 }
27 }
28  
29 #--------------------------------------------------------------------------------------
30 0 ▶sub q {
Subroutine q: not called CC=1 SCAR=6.9
Pod undocumented
31 0 my $self = shift;
32  
33 0 return $self->session->q;
34 }
35  
36 #--------------------------------------------------------------------------------------
37 0 ▶sub session {
Subroutine session: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my $self = shift;
39  
40 0 return $self->{_session};
41 }
42  
43 #--------------------------------------------------------------------------------------
44 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
45 0 my $class = shift;
46 0 my $session = shift;
47  
48 0 my $self = {_session => $session, _data => $session->getData};
49  
50 0 return bless $self, $class;
51  
52  
53 }
54  
55 1 1
56  
57 __END__
« Lazy/Widget.pm ↑ Summary Lazy/Template/Boilerplate.pm »