File Coverage

blib/lib/Apache/Voodoo/Session/Instance.pm
Criterion Covered Total %
statement 9 37 24.3
branch 0 4 0.0
condition 0 3 0.0
subroutine 3 11 27.2
pod 0 8 0.0
total 12 63 19.0


line stmt bran cond sub pod time code
1             package Apache::Voodoo::Session::Instance;
2              
3             $VERSION = "3.0200";
4              
5 2     2   1907 use strict;
  2         6  
  2         81  
6 2     2   12 use warnings;
  2         5  
  2         601  
7              
8             sub new {
9 0     0 0   my $class = shift;
10 0           my $obj = shift;
11 0           my $session = shift;
12              
13 0           my $self = {};
14              
15 0           bless $self,$class;
16              
17 0           $self->{obj} = $obj;
18 0           $self->{session} = $session;
19              
20 0           $self->{id} = $session->{_session_id};
21              
22 0           $self->{connected} = 1;
23              
24 0           return $self;
25             }
26              
27 0     0 0   sub id { return $_[0]->{id}; }
28 0     0 0   sub session { return $_[0]->{session}; }
29 0     0 0   sub obj { return $_[0]->{obj}; }
30              
31             sub has_expired {
32 0     0 0   my $self = shift;
33 0           my $timeout = shift;
34              
35 0 0 0       if ($timeout > 0 && $self->{session}->{_session_timestamp} < (time - ($timeout*60))) {
36 0           return 1;
37             }
38             else {
39 0           return 0;
40             }
41             }
42              
43             sub touch {
44 0     0 0   my $self = shift;
45              
46 0           $self->{session}->{_session_timestamp} = time;
47             }
48              
49             sub disconnect {
50 0     0 0   my $self = shift;
51              
52 0 0         if ($self->{connected}) {
53             # this produces an unavoidable warning.
54             {
55 2     2   12 no warnings;
  2         4  
  2         225  
  0            
56 0           untie(%{$self->{session}});
  0            
57             }
58 0           $self->{connected} = 0;
59             }
60             }
61              
62             sub destroy {
63 0     0 0   my $self = shift;
64              
65 0           $self->{obj}->delete;
66             }
67              
68             1;
69              
70             ################################################################################
71             # Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org).
72             # All rights reserved.
73             #
74             # You may use and distribute Apache::Voodoo under the terms described in the
75             # LICENSE file include in this package. The summary is it's a legalese version
76             # of the Artistic License :)
77             #
78             ################################################################################