line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jifty::DBI::HasFilters; |
2
|
|
|
|
|
|
|
|
3
|
36
|
|
|
36
|
|
172
|
use warnings; |
|
36
|
|
|
|
|
43
|
|
|
36
|
|
|
|
|
892
|
|
4
|
36
|
|
|
36
|
|
125
|
use strict; |
|
36
|
|
|
|
|
39
|
|
|
36
|
|
|
|
|
862
|
|
5
|
|
|
|
|
|
|
|
6
|
36
|
|
|
36
|
|
113
|
use base qw/Class::Accessor::Fast/; |
|
36
|
|
|
|
|
37
|
|
|
36
|
|
|
|
|
15231
|
|
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
|
2537
|
|
|
2537
|
1
|
2931
|
my $self = shift; |
40
|
2537
|
100
|
|
|
|
3582
|
if (@_) { # setting |
41
|
485
|
100
|
|
|
|
690
|
my @values = map { UNIVERSAL::isa( $_, 'ARRAY' ) ? @$_ : $_ } @_; |
|
485
|
|
|
|
|
3043
|
|
42
|
485
|
|
|
|
|
1382
|
$self->{input_filters} = \@values; |
43
|
485
|
|
|
|
|
1075
|
return @values; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
2052
|
100
|
|
|
|
1984
|
return @{ $self->{input_filters} || [] }; |
|
2052
|
|
|
|
|
9637
|
|
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
|
886
|
my $self = shift; |
61
|
937
|
100
|
|
|
|
1410
|
if (@_) { # setting |
62
|
96
|
50
|
|
|
|
110
|
my @values = map { UNIVERSAL::isa( $_, 'ARRAY' ) ? @$_ : $_ } @_; |
|
96
|
|
|
|
|
253
|
|
63
|
96
|
|
|
|
|
174
|
$self->{output_filters} = \@values; |
64
|
96
|
|
|
|
|
144
|
return @values; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
841
|
|
|
|
|
878
|
my $values = $self->{output_filters}; |
68
|
841
|
50
|
66
|
|
|
1914
|
return @$values if $values && @$values; |
69
|
|
|
|
|
|
|
|
70
|
841
|
|
|
|
|
1397
|
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; |