blib/lib/Mojolicious/Plugin/ServerSession.pm

filter: Statementstmt 41.9% 13 / 31 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 4 / 8 Podpod 100% 1 / 1 totaltotal 36.0% 18 / 50 CC 5 SCAR 25.9
CC
5
Cov
33%
register
30.0
__ANON__
2.0
__ANON__
2.0
CRAP 13.3
↑ Summary
1 package Mojolicious::Plugin::ServerSession;
2  
3 1 ▶use 5.010000;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Mojo::Base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.01';
9  
10  
11 0 ▶sub register {
Subroutine register: not called CC=5 SCAR=34.0
Pod documented
12 0 my ($self, $app, $conf) = (@_);
13 0 ▶ $conf ||= {};
Condition0%0/2
$conf ||= {}
l!l
00
MC/DC0%0/1
$conf ||= {}
$conf
Truth table0%0/2
A
A= $conf
Aresult
11
00
14  
15 0 ▶ my $key_name = $conf->{key} || "server_session_key";
Condition0%0/2
$conf->{'key'} || 'server_session_key'
l!l
00
MC/DC0%0/1
$conf->{'key'} || 'server_session_key'
$conf->{'key'}
Truth table0%0/2
A
A= $conf->{'key'}
Aresult
11
00
16  
17 0 ▶ die ref($self), "Missing subref parameter load" unless(ref($conf->{load}) eq "CODE");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $conf->{"load"} eq "CODE" 0 0 0
18 0 ▶ die ref($self), "Missing subref parameter store" unless(ref($conf->{store}) eq "CODE");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $conf->{"store"} eq "CODE" 0 0 0
19  
20 0 ▶ $app->plugins->on(before_dispatch => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 my $this = shift;
22  
23 0 my $key = $this->session($key_name);
24 0 my ($session_key, $session_data) = $conf->{load}->($this, $key);
25 0 $this->stash( server_session => $session_data );
26 0 $this->session( "$key_name" => $session_key );
27 0 });
28  
29 0 ▶ $app->plugins->on(after_dispatch => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 my $this = shift;
31  
32 0 my $key = $this->session($key_name);
33 0 $conf->{store}->($this, $key, $this->stash('server_session'));
34 0 });
35  
36 $app->helper(
37 0 ▶ server_session => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 0 my ($self) = @_;
39  
40 0 return $self->stash('server_session');
41 }
42 0 );
43  
44 }
45  
46  
47 1 1;
48 __END__
↑ Summary