| 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 ||= {}
MC/DC0%0/1
$conf ||= {}
$conf
Truth table0%0/2
A
A= $conf
| |||||||||||||
| 14 | |||||||||||||
| 15 | 0 | ▶ | my $key_name = $conf->{key} || "server_session_key"; | ||||||||||
|
Condition0%0/2
$conf->{'key'} || 'server_session_key'
MC/DC0%0/1
$conf->{'key'} || 'server_session_key'
$conf->{'key'}
Truth table0%0/2
A
A= $conf->{'key'}
| |||||||||||||
| 16 | |||||||||||||
| 17 | 0 | ▶ | die ref($self), "Missing subref parameter load" unless(ref($conf->{load}) eq "CODE"); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | 0 | ▶ | die ref($self), "Missing subref parameter store" unless(ref($conf->{store}) eq "CODE"); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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__ | ||||||||||||