| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dancer::SharedData; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:SUKRIA'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Shared-data singleton for Dancer |
|
4
|
|
|
|
|
|
|
$Dancer::SharedData::VERSION = '1.3514_04'; # TRIAL |
|
5
|
|
|
|
|
|
|
$Dancer::SharedData::VERSION = '1.351404'; |
|
6
|
190
|
|
|
190
|
|
1559
|
use strict; |
|
|
190
|
|
|
|
|
338
|
|
|
|
190
|
|
|
|
|
4688
|
|
|
7
|
190
|
|
|
190
|
|
812
|
use warnings; |
|
|
190
|
|
|
|
|
354
|
|
|
|
190
|
|
|
|
|
3853
|
|
|
8
|
190
|
|
|
190
|
|
64961
|
use Dancer::Timer; |
|
|
190
|
|
|
|
|
445
|
|
|
|
190
|
|
|
|
|
4310
|
|
|
9
|
190
|
|
|
190
|
|
69013
|
use Dancer::Response; |
|
|
190
|
|
|
|
|
524
|
|
|
|
190
|
|
|
|
|
4938
|
|
|
10
|
190
|
|
|
190
|
|
1141
|
use Dancer::Factory::Hook; |
|
|
190
|
|
|
|
|
371
|
|
|
|
190
|
|
|
|
|
67225
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Dancer::Factory::Hook->instance->install_hooks( |
|
13
|
|
|
|
|
|
|
qw/on_reset_state/ |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# shared variables |
|
17
|
|
|
|
|
|
|
my $vars = {}; |
|
18
|
111
|
|
|
111
|
0
|
227
|
sub vars {$vars} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub var { |
|
21
|
19
|
|
|
19
|
0
|
48
|
my ($class, $key, $value) = @_; |
|
22
|
19
|
100
|
|
|
|
51
|
$vars->{$key} = $value if (@_ == 3); |
|
23
|
19
|
|
|
|
|
43
|
return $vars->{$key}; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# request headers |
|
27
|
|
|
|
|
|
|
my $_headers; |
|
28
|
616
|
100
|
|
616
|
0
|
2510
|
sub headers { (@_ == 2) ? $_headers = $_[1] : $_headers } |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# request singleton |
|
31
|
|
|
|
|
|
|
my $_request; |
|
32
|
4008
|
100
|
|
4008
|
0
|
10576
|
sub request { (@_ == 2) ? $_request = $_[1] : $_request } |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# current response |
|
35
|
|
|
|
|
|
|
my $_response; |
|
36
|
|
|
|
|
|
|
sub response { |
|
37
|
4516
|
100
|
|
4516
|
0
|
8248
|
if (@_ == 2) { |
|
38
|
1038
|
|
|
|
|
2327
|
$_response = $_[1]; |
|
39
|
|
|
|
|
|
|
}else{ |
|
40
|
3478
|
100
|
|
|
|
7506
|
$_response = Dancer::Response->new() if !defined $_response; |
|
41
|
3478
|
|
|
|
|
6694
|
return $_response; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
} |
|
44
|
1022
|
|
|
1022
|
0
|
1976
|
sub reset_response { $_response = undef } |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# sessions singleton |
|
47
|
|
|
|
|
|
|
my $_sessions; |
|
48
|
274
|
100
|
|
274
|
0
|
843
|
sub sessions { (@_ == 2) ? $_sessions = $_[1] : $_sessions } |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# request timer |
|
51
|
|
|
|
|
|
|
my $_timer; |
|
52
|
26
|
|
66
|
26
|
0
|
178
|
sub timer { $_timer ||= Dancer::Timer->new } |
|
53
|
520
|
|
|
520
|
0
|
2037
|
sub reset_timer { $_timer = Dancer::Timer->new } |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# purging accessor |
|
56
|
|
|
|
|
|
|
sub reset_all { |
|
57
|
520
|
|
|
520
|
0
|
1043
|
my ($self, %options) = @_; |
|
58
|
520
|
|
100
|
|
|
1391
|
my $is_forward = exists($options{reset_vars}) && ! $options{reset_vars}; |
|
59
|
|
|
|
|
|
|
|
|
60
|
520
|
|
|
|
|
2288
|
Dancer::Factory::Hook->execute_hooks('on_reset_state', $is_forward); |
|
61
|
|
|
|
|
|
|
|
|
62
|
520
|
100
|
|
|
|
1272
|
if (!$is_forward) { |
|
63
|
505
|
|
|
|
|
1024
|
$vars = {}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
520
|
|
|
|
|
888
|
undef $_sessions; |
|
66
|
520
|
|
|
|
|
4535
|
undef $_request; |
|
67
|
520
|
|
|
|
|
9801
|
undef $_headers; |
|
68
|
520
|
|
|
|
|
1343
|
reset_timer(); |
|
69
|
520
|
|
|
|
|
1099
|
reset_response(); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
'Dancer::SharedData'; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |