line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jifty::DBI::HasFilters; |
2
|
|
|
|
|
|
|
|
3
|
36
|
|
|
36
|
|
252
|
use warnings; |
|
36
|
|
|
|
|
74
|
|
|
36
|
|
|
|
|
1449
|
|
4
|
36
|
|
|
36
|
|
196
|
use strict; |
|
36
|
|
|
|
|
72
|
|
|
36
|
|
|
|
|
1233
|
|
5
|
|
|
|
|
|
|
|
6
|
36
|
|
|
36
|
|
192
|
use base qw/Class::Accessor::Fast/; |
|
36
|
|
|
|
|
67
|
|
|
36
|
|
|
|
|
45917
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/ input_filters output_filters filters /); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Jifty::DBI::HasFilters - abstract class for objects that has filters |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $record = Jifty::DBI::Record->new(...); |
16
|
|
|
|
|
|
|
$record->input_filters( 'Jifty::DBI::Filter::Truncate', |
17
|
|
|
|
|
|
|
'Jifty::DBI::Filter::utf8' |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
my @filters = $record->output_filters; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This abstract class provide generic interface for setting and getting |
24
|
|
|
|
|
|
|
input and output data filters for L objects. |
25
|
|
|
|
|
|
|
You shouldn't use it directly, but L, L |
26
|
|
|
|
|
|
|
and L classes inherit this interface. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 input_filters |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Returns array of the input filters, if arguments list is not empty |
34
|
|
|
|
|
|
|
then set input filter. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub input_filters { |
39
|
2534
|
|
|
2534
|
1
|
4885
|
my $self = shift; |
40
|
2534
|
100
|
|
|
|
7078
|
if (@_) { # setting |
41
|
485
|
100
|
|
|
|
1055
|
my @values = map { UNIVERSAL::isa( $_, 'ARRAY' ) ? @$_ : $_ } @_; |
|
485
|
|
|
|
|
5820
|
|
42
|
485
|
|
|
|
|
2201
|
$self->{input_filters} = \@values; |
43
|
485
|
|
|
|
|
1500
|
return @values; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
2049
|
100
|
|
|
|
2663
|
return @{ $self->{input_filters} || [] }; |
|
2049
|
|
|
|
|
17977
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 output_filters |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Deals similar with list of output filters, but unless |
52
|
|
|
|
|
|
|
you defined own list returns reversed list of the input |
53
|
|
|
|
|
|
|
filters. In common situation you don't need to define |
54
|
|
|
|
|
|
|
own list of output filters, but use this method to get |
55
|
|
|
|
|
|
|
default list based on the input list. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub output_filters { |
60
|
937
|
|
|
937
|
1
|
1500
|
my $self = shift; |
61
|
937
|
100
|
|
|
|
2352
|
if (@_) { # setting |
62
|
96
|
50
|
|
|
|
170
|
my @values = map { UNIVERSAL::isa( $_, 'ARRAY' ) ? @$_ : $_ } @_; |
|
96
|
|
|
|
|
415
|
|
63
|
96
|
|
|
|
|
278
|
$self->{output_filters} = \@values; |
64
|
96
|
|
|
|
|
254
|
return @values; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
841
|
|
|
|
|
1539
|
my $values = $self->{output_filters}; |
68
|
841
|
50
|
66
|
|
|
5256
|
return @$values if $values && @$values; |
69
|
|
|
|
|
|
|
|
70
|
841
|
|
|
|
|
2288
|
return reverse $self->input_filters; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 filters FILTERS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Sets the input and output filters at the same time. Returns a hash, |
76
|
|
|
|
|
|
|
with keys C and C |
77
|
|
|
|
|
|
|
the respective lists. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub filters { |
82
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
83
|
|
|
|
|
|
|
return { |
84
|
0
|
|
|
|
|
|
output => $self->output_filters(@_), |
85
|
|
|
|
|
|
|
input => $self->input_filters(@_) |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SEE ALSO |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |