blib/lib/Dancer2/Core/Session.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 100% 42 / 42 CC 2 SCAR 1.8
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Dancer2/Session/Simple.pm ↑ Summary blib/lib/Dancer2/Logger/Capture.pm »
1 package Dancer2::Core::Session;
2 # ABSTRACT: class to represent any session object
3 142 $Dancer2::Core::Session::VERSION = '2.2.1';
4 142 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 142 ▶use Dancer2::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 142 ▶use Dancer2::Core::Time;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 142 has id => (
9 # for some specific plugins this should be rw.
10 # refer to https://github.com/PerlDancer/Dancer2/issues/460
11 is => 'rw',
12 isa => Str,
13 required => 1,
14 );
15  
16 has data => (
17 is => 'ro',
18 lazy => 1,
19 10063 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 142 );
21  
22 has expires => (
23 is => 'rw',
24 isa => Str,
25 coerce => sub {
26 21 ▶ my $value = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
27 21 ▶ $value += time if $value =~ /^[\-\+]?\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^[\-\+]?\d+$/ 18 3 21
28 21 Dancer2::Core::Time->new( expression => $value )->epoch;
29 },
30 142 );
31  
32 has is_dirty => (
33 is => 'rw',
34 isa => Bool,
35 10121 ▶ default => sub {0},
Subroutine __ANON__: called CC=1 SCAR=0.0
36 142 );
37  
38  
39 sub read {
40 60 ▶ my ( $self, $key ) = @_;
Subroutine read: called CC=1 SCAR=0.0
Pod documented
41 60 return $self->data->{$key};
42 }
43  
44  
45 sub write {
46 69 ▶ my ( $self, $key, $value ) = @_;
Subroutine write: called CC=1 SCAR=0.0
Pod documented
47 69 $self->is_dirty(1);
48 69 $self->data->{$key} = $value;
49 }
50  
51 sub delete {
52 9 ▶ my ( $self, $key, $value ) = @_;
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
53 9 $self->is_dirty(1);
54 9 delete $self->data->{$key};
55 }
56  
57 142 1;
58  
59 __END__
« blib/lib/Dancer2/Session/Simple.pm ↑ Summary blib/lib/Dancer2/Logger/Capture.pm »