File Coverage

blib/lib/HTTP/Session/Store/OnMemory.pm
Criterion Covered Total %
statement 25 27 92.5
branch 9 10 90.0
condition 2 2 100.0
subroutine 8 9 88.8
pod 5 6 83.3
total 49 54 90.7


line stmt bran cond sub pod time code
1             package HTTP::Session::Store::OnMemory;
2 15     15   27803 use strict;
  15         29  
  15         395  
3 15     15   66 use warnings;
  15         28  
  15         379  
4 15     15   61 use base qw/Class::Accessor::Fast/;
  15         30  
  15         5242  
5              
6             __PACKAGE__->mk_ro_accessors(qw/data/);
7              
8             sub new {
9 19     19 1 1525 my $class = shift;
10 19 50       86 my %args = ref($_[0]) ? %{$_[0]} : @_;
  0         0  
11             # set default values
12 19   100     104 $args{data} ||= {};
13 19         148 bless {%args}, $class;
14             }
15              
16             sub select {
17 29     29 1 320 my ( $self, $session_id ) = @_;
18 29 100       431 Carp::croak "missing session_id" unless $session_id;
19 27         424 $self->data->{$session_id};
20             }
21              
22             sub insert {
23 28     28 1 1962 my ($self, $session_id, $data) = @_;
24 28 100       223 Carp::croak "missing session_id" unless $session_id;
25 26         419 $self->data->{$session_id} = $data;
26             }
27              
28             sub update {
29 4     4 1 1565 my ($self, $session_id, $data) = @_;
30 4 100       166 Carp::croak "missing session_id" unless $session_id;
31 2         32 $self->data->{$session_id} = $data;
32             }
33              
34             sub delete {
35 5     5 1 1108 my ($self, $session_id) = @_;
36 5 100       169 Carp::croak "missing session_id" unless $session_id;
37 3         49 delete $self->data->{$session_id};
38             }
39              
40 0     0 0   sub cleanup { Carp::croak "This storage doesn't support cleanup" }
41              
42             1;
43             __END__