Query/Field.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 21 / 21 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Query/Field/SWISH.pm ↑ Summary
1 package Search::Query::Field;
2 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 our $VERSION = '0.306';
8  
9 9 has 'name' => ( is => 'rw' );
10 9 has 'alias_for' => ( is => 'rw' );
11 9 has 'callback' => ( is => 'rw' );
12 9 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<field_value> )
55  
56 The base method always returns true.
57  
58 =cut
59  
60 107 ▶sub validate {1}
Subroutine validate: called CC=1 SCAR=0.0
Pod documented
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 9 1;
71  
72 __END__
« Query/Field/SWISH.pm ↑ Summary