File Coverage

lib/Search/QS/Options/Sort.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Search::QS::Options::Sort;
2             $Search::QS::Options::Sort::VERSION = '0.04';
3 4     4   25 use strict;
  4         9  
  4         100  
4 4     4   17 use warnings;
  4         5  
  4         78  
5              
6 4     4   20 use Moose;
  4         8  
  4         15  
7 4     4   21117 use Moose::Util::TypeConstraints;
  4         7  
  4         30  
8              
9             # ABSTRACT: A sort element
10              
11              
12             enum 'direction_types', [qw( asc desc )];
13              
14             has name => ( is => 'rw', isa => 'Str');
15             has direction => ( is => 'rw', isa => 'direction_types', default => 'asc');
16              
17             sub to_qs() {
18 5     5 1 173 my $s = shift;
19              
20 5         113 return 'sort[' . $s->name . ']=' . $s->direction;
21             }
22              
23              
24 4     4   7753 no Moose;
  4         8  
  4         16  
25             __PACKAGE__->meta->make_immutable;
26              
27             1;
28              
29             __END__
30              
31             =pod
32              
33             =encoding UTF-8
34              
35             =head1 NAME
36              
37             Search::QS::Options::Sort - A sort element
38              
39             =head1 VERSION
40              
41             version 0.04
42              
43             =head1 DESCRIPTION
44              
45             This object incapsulate a single sort item.
46              
47             =head1 METHODS
48              
49             =head2 name()
50              
51             The field to sort
52              
53             =head2 direction()
54              
55             The type of sort (asc|desc)
56              
57             =head2 to_qs()
58              
59             Return a query string of the internal rappresentation of the object
60              
61             =head1 AUTHOR
62              
63             Emiliano Bruni <info@ebruni.it>
64              
65             =head1 COPYRIGHT AND LICENSE
66              
67             This software is copyright (c) 2019 by Emiliano Bruni.
68              
69             This is free software; you can redistribute it and/or modify it under
70             the same terms as the Perl 5 programming language system itself.
71              
72             =cut