| 1 | package Plack::Session; | ||
| 2 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 6 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 6 | our $VERSION = '0.36'; | |
| 6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; | |
| 7 | |||
| 8 | 6 | ▶ | use Plack::Util::Accessor qw( session options ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 45 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 11 | 45 | my ($class, $env) = @_; | |
| 12 | bless { | ||
| 13 | session => $env->{'psgix.session'}, | ||
| 14 | 45 | options => $env->{'psgix.session.options'}, | |
| 15 | }, $class; | ||
| 16 | } | ||
| 17 | |||
| 18 | 50 | ▶ | sub id { |
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||
| 19 | 50 | my $self = shift; | |
| 20 | 50 | $self->options->{id}; | |
| 21 | } | ||
| 22 | |||
| 23 | ## Data Managment | ||
| 24 | |||
| 25 | 45 | ▶ | sub dump { |
|
Subroutine
dump: called CC=1 SCAR=0.0
Pod
documented
| |||
| 26 | 45 | my $self = shift; | |
| 27 | 45 | $self->session; | |
| 28 | } | ||
| 29 | |||
| 30 | 75 | ▶ | sub get { |
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||
| 31 | 75 | my ($self, $key) = @_; | |
| 32 | 75 | $self->session->{$key}; | |
| 33 | } | ||
| 34 | |||
| 35 | 25 | ▶ | sub set { |
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||
| 36 | 25 | my ($self, $key, $value) = @_; | |
| 37 | 25 | delete $self->options->{no_store}; | |
| 38 | 25 | $self->session->{$key} = $value; | |
| 39 | } | ||
| 40 | |||
| 41 | 5 | ▶ | sub remove { |
|
Subroutine
remove: called CC=1 SCAR=0.0
Pod
documented
| |||
| 42 | 5 | my ($self, $key) = @_; | |
| 43 | 5 | delete $self->options->{no_store}; | |
| 44 | 5 | delete $self->session->{$key}; | |
| 45 | } | ||
| 46 | |||
| 47 | 5 | ▶ | sub keys { |
|
Subroutine
keys: called CC=1 SCAR=0.0
Pod
documented
| |||
| 48 | 5 | my $self = shift; | |
| 49 | 5 | keys %{$self->session}; | |
| 50 | } | ||
| 51 | |||
| 52 | ## Lifecycle Management | ||
| 53 | |||
| 54 | 5 | ▶ | sub expire { |
|
Subroutine
expire: called CC=2 SCAR=6.9
Pod
documented
| |||
| 55 | 5 | my $self = shift; | |
| 56 | 5 | for my $key ($self->keys) { | |
| 57 | 10 | delete $self->session->{$key}; | |
| 58 | } | ||
| 59 | 5 | $self->options->{expire} = 1; | |
| 60 | } | ||
| 61 | |||
| 62 | 6 | 1; | |
| 63 | |||
| 64 | __END__ | ||