File Coverage

blib/lib/Search/Query/Field/SWISH.pm
Criterion Covered Total %
statement 11 11 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 3 3 100.0
pod 1 1 100.0
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Search::Query::Field::SWISH;
2 3     3   18 use Moo;
  3         6  
  3         18  
3             extends 'Search::Query::Field';
4              
5 3     3   868 use namespace::autoclean;
  3         7  
  3         36  
6              
7             has 'type' => ( is => 'rw' );
8             has 'is_int' => ( is => 'rw' );
9              
10             our $VERSION = '0.306';
11              
12             =head1 NAME
13              
14             Search::Query::Field::SWISH - query field representing a Swish MetaName
15              
16             =head1 SYNOPSIS
17              
18             my $field = Search::Query::Field::SWISH->new(
19             name => 'foo',
20             alias_for => [qw( bar bing )],
21             );
22              
23             =head1 DESCRIPTION
24              
25             Search::Query::Field::SWISH implements field
26             validation and aliasing in SWISH search queries.
27              
28             =head1 METHODS
29              
30             This class is a subclass of Search::Query::Field. Only new or overridden
31             methods are documented here.
32              
33             =head2 BUILD
34              
35             Available params are also standard attribute accessor methods.
36              
37             =over
38              
39             =item type
40              
41             The column type.a
42              
43             =item is_int
44              
45             Set if C matches m/int|num|date/.
46              
47             =back
48              
49             =cut
50              
51             sub BUILD {
52 25     25 1 3980 my $self = shift;
53              
54 25   100     135 $self->{type} ||= 'char';
55              
56             # numeric types
57 25 100       126 if ( $self->{type} =~ m/int|date|num/ ) {
58 1         28 $self->{is_int} = 1;
59             }
60              
61             # text types
62             else {
63 24         669 $self->{is_int} = 0;
64             }
65              
66             }
67              
68             1;
69              
70             __END__