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
« 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 144 $Dancer2::Core::Session::VERSION = '2.3.0';
4 144 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 144 ▶use Dancer2::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 144 ▶use Dancer2::Core::Time;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 144 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 144 );
21  
22 has expires => (
23 is => 'rw',
24 isa => Str,
25 21 ▶ coerce => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
26 21 my $value = shift;
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 144 );
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 144 );
37  
38  
39 60 ▶sub read {
Subroutine read: called CC=1 SCAR=0.0
Pod documented
40 60 my ( $self, $key ) = @_;
41 60 return $self->data->{$key};
42 }
43  
44  
45 69 ▶sub write {
Subroutine write: called CC=1 SCAR=0.0
Pod documented
46 69 my ( $self, $key, $value ) = @_;
47 69 $self->is_dirty(1);
48 69 $self->data->{$key} = $value;
49 }
50  
51 9 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
52 9 my ( $self, $key, $value ) = @_;
53 9 $self->is_dirty(1);
54 9 delete $self->data->{$key};
55 }
56  
57 144 1;
58  
59 __END__
« lib/Dancer2/Session/Simple.pm ↑ Summary blib/lib/Dancer2/Logger/Capture.pm »