| 1 | package CGI::Session::Driver::chi; | ||||||||||||
| 2 | =head1 NAME | ||||||||||||
| 3 | |||||||||||||
| 4 | CGI::Session::Driver::chi | ||||||||||||
| 5 | |||||||||||||
| 6 | =cut | ||||||||||||
| 7 | |||||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||||
| 9 | |||||||||||||
| 10 | $s = CGI::Session->new( | ||||||||||||
| 11 | "driver:chi", | ||||||||||||
| 12 | $sid, { | ||||||||||||
| 13 | driver => 'File', | ||||||||||||
| 14 | root_dir => '/path/to/root' | ||||||||||||
| 15 | }); | ||||||||||||
| 16 | |||||||||||||
| 17 | $s = CGI::Session->new( | ||||||||||||
| 18 | "driver:chi", | ||||||||||||
| 19 | $sid, { | ||||||||||||
| 20 | chi_class => 'My::CHI', | ||||||||||||
| 21 | namespace => 'cgi', | ||||||||||||
| 22 | }); | ||||||||||||
| 23 | |||||||||||||
| 24 | |||||||||||||
| 25 | |||||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||||
| 27 | |||||||||||||
| 28 | This driver allows L<CGI::Session> to use L<CHI> as a session store | ||||||||||||
| 29 | |||||||||||||
| 30 | =cut | ||||||||||||
| 31 | |||||||||||||
| 32 | =head2 DRIVER ARGUMENTS | ||||||||||||
| 33 | |||||||||||||
| 34 | It accept a hash ref with the same arguements to would pass to L<CHI> | ||||||||||||
| 35 | |||||||||||||
| 36 | An additional arguement chi_class | ||||||||||||
| 37 | |||||||||||||
| 38 | =cut | ||||||||||||
| 39 | |||||||||||||
| 40 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 41 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 42 | |||||||||||||
| 43 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 44 | 1 | ▶ | use CHI; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 45 | 1 | ▶ | use base qw( CGI::Session::Driver CGI::Session::ErrorHandler ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 46 | |||||||||||||
| 47 | 1 | our $VERSION = '1.0.3'; | |||||||||||
| 48 | |||||||||||||
| 49 | 0 | ▶ | sub init { | ||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 50 | 0 | my ($self) = @_; | |||||||||||
| 51 | 0 | my %args = %$self; | |||||||||||
| 52 | 0 | ▶ | my $chi_class = delete $args{chi_class} || "CHI"; | ||||||||||
|
Condition0%0/2
delete $args{'chi_class'} || 'CHI'
MC/DC0%0/1
delete $args{'chi_class'} || 'CHI'
delete $args{'chi_class'}
Truth table0%0/2
A
A= delete $args{'chi_class'}
| |||||||||||||
| 53 | 0 | my $chi = $chi_class->new(%args); | |||||||||||
| 54 | 0 | $self->{CHI} = $chi; | |||||||||||
| 55 | 0 | return 1; | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | 0 | ▶ | sub store { | ||||||||||
|
Subroutine
store: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 59 | 0 | my ($self, $sid, $datastr) = @_; | |||||||||||
| 60 | 0 | $self->{CHI}->set($sid, $datastr); | |||||||||||
| 61 | 0 | return 1; | |||||||||||
| 62 | } | ||||||||||||
| 63 | |||||||||||||
| 64 | 0 | ▶ | sub retrieve { | ||||||||||
|
Subroutine
retrieve: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 65 | 0 | my ($self, $sid) = @_; | |||||||||||
| 66 | 0 | my $value = $self->{CHI}->get($sid); | |||||||||||
| 67 | 0 | ▶ | return 0 unless defined $value; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 68 | 0 | return $value; | |||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | 0 | ▶ | sub remove { | ||||||||||
|
Subroutine
remove: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 72 | 0 | my ($self, $sid) = @_; | |||||||||||
| 73 | 0 | $self->{CHI}->remove($sid); | |||||||||||
| 74 | 0 | return 1; | |||||||||||
| 75 | } | ||||||||||||
| 76 | |||||||||||||
| 77 | 0 | ▶ | sub traverse { | ||||||||||
|
Subroutine
traverse: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 78 | 0 | my ($self, $coderef) = @_; | |||||||||||
| 79 | 0 | foreach my $key ($self->{CHI}->get_keys) { | |||||||||||
| 80 | 0 | $coderef->( $key ) | |||||||||||
| 81 | } | ||||||||||||
| 82 | 0 | return 1; | |||||||||||
| 83 | } | ||||||||||||
| 84 | |||||||||||||
| 85 | =head1 AUTHOR | ||||||||||||
| 86 | |||||||||||||
| 87 | James Rouzier. <rouzier@gmail.com> | ||||||||||||
| 88 | |||||||||||||
| 89 | =head1 COPYRIGHT | ||||||||||||
| 90 | |||||||||||||
| 91 | Copyright (C) 2013 James Rouzier | ||||||||||||
| 92 | |||||||||||||
| 93 | =head1 LICENSE | ||||||||||||
| 94 | |||||||||||||
| 95 | This program is free software; you can redistribute it and/or | ||||||||||||
| 96 | modify it under the terms of the GNU General Public License | ||||||||||||
| 97 | as published by the Free Software Foundation; either version 2 | ||||||||||||
| 98 | of the License, or (at your option) any later version. | ||||||||||||
| 99 | |||||||||||||
| 100 | This program is distributed in the hope that it will be useful, | ||||||||||||
| 101 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||
| 102 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||
| 103 | GNU General Public License for more details. | ||||||||||||
| 104 | |||||||||||||
| 105 | You should have received a copy of the GNU General Public License | ||||||||||||
| 106 | along with this program; if not, write to the Free Software | ||||||||||||
| 107 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||||||||||||
| 108 | USA. | ||||||||||||
| 109 | |||||||||||||
| 110 | =cut | ||||||||||||
| 111 | |||||||||||||
| 112 | 1 | 1; | |||||||||||