File Coverage

blib/lib/Dancer/Session/Simple.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 4 4 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             package Dancer::Session::Simple;
2             our $AUTHORITY = 'cpan:SUKRIA';
3             #ABSTRACT: in-memory session backend for Dancer
4             $Dancer::Session::Simple::VERSION = '1.3514_04'; # TRIAL
5             $Dancer::Session::Simple::VERSION = '1.351404';
6 91     91   40395 use strict;
  91         202  
  91         2470  
7 91     91   429 use warnings;
  91         160  
  91         2218  
8 91     91   401 use base 'Dancer::Session::Abstract';
  91         173  
  91         35194  
9              
10             my %sessions;
11              
12             # create a new session and return the newborn object
13             # representing that session
14             sub create {
15 35     35 1 1221 my ($class) = @_;
16              
17 35         184 my $self = Dancer::Session::Simple->new;
18 35         140 $self->flush;
19 35         86 return $self;
20             }
21              
22             # Return the session object corresponding to the given id
23             sub retrieve {
24 67     67 1 145 my ($class, $id) = @_;
25              
26 67         167 return $sessions{$id};
27             }
28              
29              
30             sub destroy {
31 1     1 1 6 my ($self) = @_;
32 1         4 undef $sessions{$self->id};
33             }
34              
35             sub flush {
36 43     43 1 672 my $self = shift;
37 43         125 $sessions{$self->id} = $self;
38 43         76 return $self;
39             }
40              
41             1;
42              
43             __END__