EntityModel/Query/OrderField.pm

filter: Statementstmt 100% 22 / 22 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 94.2% 33 / 35 CC 6 SCAR 12.4
CC
6
Cov
93%
__ANON__
5.0
asString
2.0
import
1.0
CRAP 3.5
« EntityModel/Query/Update.pm ↑ Summary EntityModel/Field.pm »
1 package EntityModel::Query::OrderField;
2 {
3 34 $EntityModel::Query::OrderField::VERSION = '0.102';
4 }
5 34 ▶use EntityModel::Class {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 34 _isa => [qw{EntityModel::Query::Field}],
7 direction => { type => 'int' }
8 34 };
9  
10 =head1 NAME
11  
12 EntityModel::Query::OrderField - define a field for ORDER BY clause
13  
14 =head1 VERSION
15  
16 version 0.102
17  
18 =head1 SYNOPSIS
19  
20 See L<Entitymodel::Query>.
21  
22 =head1 DESCRIPTION
23  
24 See L<Entitymodel::Query>.
25  
26 =cut
27  
28 =head1 METHODS
29  
30 =cut
31  
32 =head2 import
33  
34 Register parse handling.
35  
36 =cut
37  
38 33 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
39 33 my $class = shift;
40 $class->register(
41 2 ▶ 'order' => sub {
Subroutine __ANON__: called CC=5 SCAR=16.2
42 2 my $self = shift;
43 2 my $v = shift;
44 2 ▶ my @comp = (ref $v eq 'ARRAY') ? @$v : $v;
Branch: 1 branch
BranchTrueFalseTotal
ref $v eq 'ARRAY' ? : 0 2 2
45  
46 2 foreach my $entry (@comp) {
47 2 ▶ if(ref $entry eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $entry eq 'HASH') { } 1 1 2
48 1 my ($dir, $field) = %$entry;
49  
50 1 my $o = EntityModel::Query::OrderField->new($field);
51 1 ▶ $o->direction($dir eq 'desc' ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$dir eq 'desc' ? : 1 0 1
52 1 $self->order->push($o);
53 } else {
54 1 my $o = EntityModel::Query::OrderField->new($entry);
55 1 $self->order->push($o);
56 }
57 }
58 2 return $self;
59 }
60 33 );
61 }
62  
63 =head2 asString
64  
65 =cut
66  
67 4 ▶sub asString {
Subroutine asString: called CC=2 SCAR=6.9
Pod documented
68 4 my $self = shift;
69 4 ▶ return $self->SUPER::asString(@_) . ($self->direction ? ' desc' : '');
Branch: 1 branch
BranchTrueFalseTotal
$self->direction ? : 2 2 4
70 }
71  
72 34 1;
73  
74 __END__
« EntityModel/Query/Update.pm ↑ Summary EntityModel/Field.pm »