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