File Coverage

blib/lib/Data/Session/ID/Static.pm
Criterion Covered Total %
statement 18 24 75.0
branch 0 2 0.0
condition n/a
subroutine 6 8 75.0
pod 1 3 33.3
total 25 37 67.5


line stmt bran cond sub pod time code
1             package Data::Session::ID::Static;
2              
3 1     1   586 use parent 'Data::Session::ID';
  1         2  
  1         8  
4 1     1   66 no autovivification;
  1         2  
  1         7  
5 1     1   45 use strict;
  1         2  
  1         19  
6 1     1   4 use warnings;
  1         2  
  1         31  
7              
8 1     1   4 use Hash::FieldHash ':all';
  1         2  
  1         315  
9              
10             our $VERSION = '1.17';
11              
12             # -----------------------------------------------
13              
14             sub generate
15             {
16 0     0 0 0 my($self) = @_;
17 0         0 my($id) = $self -> id;
18              
19 0 0       0 (! $id) && die __PACKAGE__ . '. Static id (supplied to new) is not a true value';
20              
21 0         0 return $id;
22              
23             } # End of generate.
24              
25             # -----------------------------------------------
26              
27             sub id_length
28             {
29 0     0 0 0 my($self) = @_;
30              
31 0         0 return 32;
32              
33             } # End of id_length.
34              
35             # -----------------------------------------------
36              
37             sub new
38             {
39 30     30 1 222 my($class, %arg) = @_;
40              
41 30         118 $class -> init(\%arg);
42              
43 30         1678 return from_hash(bless({}, $class), \%arg);
44              
45             } # End of new.
46              
47             # -----------------------------------------------
48              
49             1;
50              
51             =pod
52              
53             =head1 NAME
54              
55             L - A persistent session manager
56              
57             =head1 Synopsis
58              
59             See L for details.
60              
61             =head1 Description
62              
63             L allows L to generate a static (constant) session id.
64              
65             To use this module do this:
66              
67             =over 4
68              
69             =item o Specify an id generator of type Static, as Data::Session -> new(type => '... id:Static ...')
70              
71             =back
72              
73             =head1 Case-sensitive Options
74              
75             See L for important information.
76              
77             =head1 Method: new()
78              
79             Creates a new object of type L.
80              
81             C takes a hash of key/value pairs, some of which might mandatory. Further, some combinations
82             might be mandatory.
83              
84             The keys are listed here in alphabetical order.
85              
86             They are lower-case because they are (also) method names, meaning they can be called to set or get
87             the value at any time.
88              
89             =over 4
90              
91             =item o id => $string
92              
93             Specifies the static (constant) id to 'generate'.
94              
95             This key is normally passed in as Data::Session -> new(id => $string).
96              
97             Default: 0.
98              
99             This key is mandatory, and can't be 0.
100              
101             =item o verbose => $integer
102              
103             Print to STDERR more or less information.
104              
105             Typical values are 0, 1 and 2.
106              
107             This key is normally passed in as Data::Session -> new(verbose => $integer).
108              
109             This key is optional.
110              
111             =back
112              
113             =head1 Method: generate()
114              
115             Generates the next session id (which is always what was passed in to new(id => ...) ), or dies if it
116             can't.
117              
118             Returns the new id.
119              
120             =head1 Method: id_length()
121              
122             Returns 32 because that's the classic value of the size of the id field in the sessions table.
123              
124             This can be used to generate the SQL to create the sessions table.
125              
126             =head1 Support
127              
128             Log a bug on RT: L.
129              
130             =head1 Author
131              
132             L was written by Ron Savage Iron@savage.net.auE> in 2010.
133              
134             Home page: L.
135              
136             =head1 Copyright
137              
138             Australian copyright (c) 2010, Ron Savage.
139              
140             All Programs of mine are 'OSI Certified Open Source Software';
141             you can redistribute them and/or modify them under the terms of
142             The Artistic License, a copy of which is available at:
143             http://www.opensource.org/licenses/index.html
144              
145             =cut