line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package EntityModel::Query::OrderField; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$EntityModel::Query::OrderField::VERSION = '0.102'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
use EntityModel::Class { |
6
|
16
|
|
|
|
|
344
|
_isa => [qw{EntityModel::Query::Field}], |
7
|
|
|
|
|
|
|
direction => { type => 'int' } |
8
|
16
|
|
|
16
|
|
15193
|
}; |
|
16
|
|
|
|
|
31
|
|
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. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
See L. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 import |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Register parse handling. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub import { |
39
|
16
|
|
|
16
|
|
37
|
my $class = shift; |
40
|
|
|
|
|
|
|
$class->register( |
41
|
|
|
|
|
|
|
'order' => sub { |
42
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
43
|
2
|
|
|
|
|
2
|
my $v = shift; |
44
|
2
|
50
|
|
|
|
8
|
my @comp = (ref $v eq 'ARRAY') ? @$v : $v; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
6
|
foreach my $entry (@comp) { |
47
|
2
|
100
|
|
|
|
6
|
if(ref $entry eq 'HASH') { |
48
|
1
|
|
|
|
|
4
|
my ($dir, $field) = %$entry; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
7
|
my $o = EntityModel::Query::OrderField->new($field); |
51
|
1
|
50
|
|
|
|
8
|
$o->direction($dir eq 'desc' ? 1 : 0); |
52
|
1
|
|
|
|
|
11
|
$self->order->push($o); |
53
|
|
|
|
|
|
|
} else { |
54
|
1
|
|
|
|
|
13
|
my $o = EntityModel::Query::OrderField->new($entry); |
55
|
1
|
|
|
|
|
4
|
$self->order->push($o); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
2
|
|
|
|
|
239
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
16
|
|
|
|
|
255
|
); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 asString |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub asString { |
68
|
4
|
|
|
4
|
1
|
5
|
my $self = shift; |
69
|
4
|
100
|
|
|
|
32
|
return $self->SUPER::asString(@_) . ($self->direction ? ' desc' : ''); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |