| 1 | package Search::Query::Field::SWISH; | ||||||||||||
| 2 | 4 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 4 | extends 'Search::Query::Field'; | |||||||||||
| 4 | |||||||||||||
| 5 | 4 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 4 | has 'type' => ( is => 'rw' ); | |||||||||||
| 8 | 4 | has 'is_int' => ( is => 'rw' ); | |||||||||||
| 9 | |||||||||||||
| 10 | 4 | 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<type> matches m/int|num|date/. | ||||||||||||
| 46 | |||||||||||||
| 47 | =back | ||||||||||||
| 48 | |||||||||||||
| 49 | =cut | ||||||||||||
| 50 | |||||||||||||
| 51 | sub BUILD { | ||||||||||||
| 52 | 25 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
BUILD: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 53 | |||||||||||||
| 54 | 25 | ▶ | $self->{type} ||= 'char'; | ||||||||||
|
Condition100%2/2
$self->{"type"} ||= "char"
MC/DC100%1/1
$self->{"type"} ||= "char"
$self->{"type"}
Truth table100%2/2
A
A= $self->{"type"}
| |||||||||||||
| 55 | |||||||||||||
| 56 | # numeric types | ||||||||||||
| 57 | 25 | ▶ | if ( $self->{type} =~ m/int|date|num/ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 58 | 1 | $self->{is_int} = 1; | |||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | # text types | ||||||||||||
| 62 | else { | ||||||||||||
| 63 | 24 | $self->{is_int} = 0; | |||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | } | ||||||||||||
| 67 | |||||||||||||
| 68 | 4 | 1; | |||||||||||
| 69 | |||||||||||||
| 70 | __END__ | ||||||||||||