line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Search::Query::Field; |
2
|
8
|
|
|
8
|
|
54
|
use Moo; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
44
|
|
3
|
8
|
|
|
8
|
|
2420
|
use Carp; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
506
|
|
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
45
|
use namespace::autoclean; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.305'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'name' => ( is => 'rw' ); |
10
|
|
|
|
|
|
|
has 'alias_for' => ( is => 'rw' ); |
11
|
|
|
|
|
|
|
has 'callback' => ( is => 'rw' ); |
12
|
|
|
|
|
|
|
has 'error' => ( is => 'rw' ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Search::Query::Field - base class for query fields |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $field = Search::Query::Field->new( |
21
|
|
|
|
|
|
|
name => 'foo', |
22
|
|
|
|
|
|
|
alias_for => [qw( bar bing )], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Search::Query::Field is a base class for implementing field |
28
|
|
|
|
|
|
|
validation and aliasing in search queries. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 name |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Get/set the name of the field. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 alias_for |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Get/set the alternate names for the field. Can be a string or array ref. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 callback |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Standard attribute accessor. Expects a CODE reference. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
If defined on a Field object, the callback is invoked whenever a Clause |
45
|
|
|
|
|
|
|
is stringified or serialized. The CODE reference should expect 3 arguments: |
46
|
|
|
|
|
|
|
the field name, the operator and the value. It should return a serialized |
47
|
|
|
|
|
|
|
or serializable value. Example: |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$field->callback(sub { |
50
|
|
|
|
|
|
|
my ($field, $op, $value) = @_; |
51
|
|
|
|
|
|
|
return "$field $op $value"; |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 validate( I ) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
The base method always returns true. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
107
|
|
|
107
|
1
|
549
|
sub validate {1} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 error |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Get/set the error string for the Field object. The return value |
65
|
|
|
|
|
|
|
of this method is included by the Parser in any error message |
66
|
|
|
|
|
|
|
whenever validate() returns false. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |