| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Jifty::DBI::Filter::Storable; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
39
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw|Jifty::DBI::Filter|; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
312
|
|
|
7
|
1
|
|
|
1
|
|
3470
|
use Storable (); |
|
|
1
|
|
|
|
|
8560
|
|
|
|
1
|
|
|
|
|
174
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Jifty::DBI::Filter::Storable - Encodes arbitrary data using Storable |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This filter allows you to store arbitrary Perl data structures in a |
|
16
|
|
|
|
|
|
|
column of type 'blob', using L to serialize them. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 encode |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
If value is defined, then encodes it using L. Does |
|
21
|
|
|
|
|
|
|
nothing if value is not defined. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub encode { |
|
26
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
15
|
my $value_ref = $self->value_ref; |
|
29
|
2
|
100
|
|
|
|
29
|
return unless defined $$value_ref; |
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
2
|
$Storable::Deparse = 1; |
|
32
|
1
|
|
|
|
|
3
|
$$value_ref = Storable::nfreeze($value_ref); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 decode |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
If value is defined, then decodes it using L, otherwise |
|
38
|
|
|
|
|
|
|
does nothing. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub decode { |
|
43
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
|
44
|
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
10
|
my $value_ref = $self->value_ref; |
|
46
|
2
|
100
|
|
|
|
19
|
return unless defined $$value_ref; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Storable doesn't take Unicode strings. |
|
49
|
1
|
|
|
|
|
7
|
Encode::_utf8_off($$value_ref); |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
2
|
local $@; |
|
52
|
1
|
|
|
|
|
4
|
$Storable::Eval = 1; |
|
53
|
1
|
|
|
|
|
3
|
$$value_ref = eval { ${ Storable::thaw($$value_ref) } }; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
L, L |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |