blib/lib/Dancer2/Session/Simple.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 37 / 37 CC 2 SCAR 2.0
CC
2
Cov
100%
_retrieve
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Dancer2/CLI.pm ↑ Summary blib/lib/Dancer2/Core/Session.pm »
1 package Dancer2::Session::Simple;
2 # ABSTRACT: in-memory session backend for Dancer2
3 136 $Dancer2::Session::Simple::VERSION = '2.2.1';
4 136 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 136 ▶use Dancer2::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 136 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 136 with 'Dancer2::Core::Role::SessionFactory';
9  
10 # The singleton that contains all the session objects created
11 136 my $SESSIONS = {};
12  
13 sub _sessions {
14 3 ▶ my ($self) = @_;
Subroutine _sessions: called CC=1 SCAR=0.0
15 3 return [ keys %{$SESSIONS} ];
16 }
17  
18 sub _retrieve {
19 36 ▶ my ( $class, $id ) = @_;
Subroutine _retrieve: called CC=2 SCAR=6.9
20 36 my $s = $SESSIONS->{$id};
21  
22 36 ▶ croak "Invalid session ID: $id"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $s 4 32 36
23 if !defined $s;
24  
25 32 return $s;
26 }
27  
28 sub _change_id {
29 3 ▶ my ( $class, $old_id, $new_id ) = @_;
Subroutine _change_id: called CC=1 SCAR=0.0
30  
31 3 $SESSIONS->{$new_id} = $class->_retrieve($old_id);
32 3 delete $SESSIONS->{$old_id};
33 }
34  
35 sub _destroy {
36 8 ▶ my ( $class, $id ) = @_;
Subroutine _destroy: called CC=1 SCAR=0.0
37 8 delete $SESSIONS->{$id};
38 }
39  
40 sub _flush {
41 10090 ▶ my ( $class, $id, $data ) = @_;
Subroutine _flush: called CC=1 SCAR=0.0
42 10090 $SESSIONS->{$id} = $data;
43 }
44  
45 136 1;
46  
47 __END__
« blib/lib/Dancer2/CLI.pm ↑ Summary blib/lib/Dancer2/Core/Session.pm »