| 1 | package Plack::Session::Store::Transparent; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use 5.008005; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | our $VERSION = "0.03"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use parent 'Plack::Session::Store'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Plack::Util::Accessor qw( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | origin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | cache | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 21 | ▶ | sub _check_interface { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_interface: called CC=4 SCAR=18.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 21 | my ($class, $obj) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 21 | ▶ | return blessed $obj | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
builtin::blessed($obj) && $obj->can('fetch') && $obj->can('store') && $obj->can('remove')
builtin::blessed($obj) and $obj->can("fetch") and $obj->can("store")
builtin::blessed($obj) and $obj->can("fetch")
MC/DC0%0/4
builtin::blessed($obj) && $obj->can('fetch') && $obj->can('store') && $obj->can('remove')
builtin::blessed($obj)
$obj->can("fetch")
$obj->can("store")
$obj->can('remove')
Truth table20%1/5
A and B and C && D
A= builtin::blessed($obj)B= $obj->can("fetch")C= $obj->can("store")D= $obj->can('remove')
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | && $obj->can('fetch') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | && $obj->can('store') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | && $obj->can('remove'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 7 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | ▶ | unless ($args{origin}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | croak "missing mandatory parameter 'origin'"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # check origin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 7 | croak 'origin requires fetch, store and remove method' | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 7 | ▶ | unless $class->_check_interface($args{origin}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # check cache | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 7 | ▶ | my @caches = ( ref($args{cache}) eq 'ARRAY' ? @{ $args{cache} } : $args{cache} ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 7 | for (@caches) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 14 | ▶ | next unless $_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 14 | ▶ | croak 'cache requires fetch, store and remove method' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | unless $class->_check_interface($_); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | return bless { %args }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 15 | ▶ | sub fetch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 15 | my ($self, $session_id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 15 | my @uppers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 15 | for my $layer ($self->_layers) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 28 | ▶ | if (my $session = $layer->fetch($session_id)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # ignore exceptions for availability | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 11 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 11 | $_->store($session_id, $session) for @uppers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 11 | return $session; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 17 | unshift(@uppers, $layer); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 13 | ▶ | sub store { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
store: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 13 | my ($self, $session_id, $session) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 13 | my @uppers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 13 | for my $layer ($self->_layers) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 38 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 38 | $layer->store($session_id, $session); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 38 | ▶ | if (my $e = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | $_->remove($session_id) for @uppers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | croak $e; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 37 | push(@uppers, $layer); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | my ($self, $session_id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | for my $layer ($self->_layers) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 8 | $layer->remove($session_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 31 | ▶ | sub _caches { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_caches: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 31 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 31 | ▶ | return [] unless $self->cache; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 31 | ▶ | return ref($self->cache) eq 'ARRAY' ? $self->cache : [ $self->cache ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 31 | ▶ | sub _layers { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_layers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 31 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 31 | return (@{ $self->_caches }, $self->origin); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||