line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Session::Store::Catmandu; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Plack::Session::Store::Catmandu - Plack session store backed by a Catmandu::Store |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Version 0.02 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Plack::Builder; |
18
|
|
|
|
|
|
|
use Plack::Middleware::Session; |
19
|
|
|
|
|
|
|
use Plack::Session::Store::Catmandu; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $app = sub { |
22
|
|
|
|
|
|
|
return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello' ] ]; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
builder { |
26
|
|
|
|
|
|
|
enable 'Session', store => Plack::Session::Store::Catmandu->new( |
27
|
|
|
|
|
|
|
store => 'MongoDB', |
28
|
|
|
|
|
|
|
bag => 'sessions', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
$app; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
|
1803
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
203334
|
|
|
1
|
|
|
|
|
5
|
|
36
|
1
|
|
|
1
|
|
1214
|
use parent qw(Plack::Session::Store); |
|
1
|
|
|
|
|
309
|
|
|
1
|
|
|
|
|
5
|
|
37
|
1
|
|
|
1
|
|
3369
|
use Catmandu; |
|
1
|
|
|
|
|
299656
|
|
|
1
|
|
|
|
|
8
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub new { |
40
|
0
|
|
|
0
|
1
|
|
my ($class, %opts) = @_; |
41
|
0
|
|
0
|
|
|
|
my $store = $opts{store} || Catmandu->default_store; |
42
|
0
|
|
0
|
|
|
|
my $bag = $opts{bag} || 'session'; |
43
|
0
|
|
|
|
|
|
bless { |
44
|
|
|
|
|
|
|
bag => Catmandu->store($store)->bag($bag), |
45
|
|
|
|
|
|
|
}, $class; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub fetch { |
49
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = @_; |
50
|
0
|
|
0
|
|
|
|
my $obj = $self->{bag}->get($id) || return; |
51
|
0
|
|
|
|
|
|
delete $obj->{_id}; |
52
|
0
|
|
|
|
|
|
$obj; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub store { |
56
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $obj) = @_; |
57
|
0
|
|
|
|
|
|
$obj->{_id} = $id; |
58
|
0
|
|
|
|
|
|
$self->{bag}->add($obj); |
59
|
0
|
|
|
|
|
|
delete $obj->{_id}; |
60
|
0
|
|
|
|
|
|
$obj; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub remove { |
64
|
0
|
|
|
0
|
1
|
|
my ($self, $id) = @_; |
65
|
0
|
|
|
|
|
|
$self->{bag}->delete($id); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L, L |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Nicolas Steenlant, C<< >> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
81
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
82
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |