line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jifty::DBI::Filter::Storable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw|Jifty::DBI::Filter|; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
7
|
1
|
|
|
1
|
|
515
|
use Storable (); |
|
1
|
|
|
|
|
2116
|
|
|
1
|
|
|
|
|
121
|
|
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
|
3
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
6
|
my $value_ref = $self->value_ref; |
29
|
2
|
100
|
|
|
|
15
|
return unless defined $$value_ref; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
1
|
$Storable::Deparse = 1; |
32
|
1
|
|
|
|
|
2
|
$$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
|
2
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
7
|
my $value_ref = $self->value_ref; |
46
|
2
|
100
|
|
|
|
13
|
return unless defined $$value_ref; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Storable doesn't take Unicode strings. |
49
|
1
|
|
|
|
|
3
|
Encode::_utf8_off($$value_ref); |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
1
|
local $@; |
52
|
1
|
|
|
|
|
2
|
$Storable::Eval = 1; |
53
|
1
|
|
|
|
|
2
|
$$value_ref = eval { ${ Storable::thaw($$value_ref) } }; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SEE ALSO |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
L, L |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |