Helper/ResultSet/Shortcut/OrderByMagic.pm

filter: Statementstmt 100% 23 / 23 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 92.3% 36 / 39 CC 7 SCAR 16.5
CC
7
Cov
94%
order_by
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
« Helper/Row/OnColumnChange.pm ↑ Summary Helper/Row/ProxyResultSetUpdate.pm »
1 package DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic;
2 57 $DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic::VERSION = '2.037000';
3 57 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 57 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 57 ▶use parent 'DBIx::Class::Helper::ResultSet::Shortcut::OrderBy', 'DBIx::Class::ResultSet';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 ▶sub order_by {
Subroutine order_by: called CC=7 SCAR=19.5
Pod documented
9 8 my ($self, @order) = @_;
10  
11 8 ▶ return $self->next::method(@order)
Branch: 1 branch
BranchTrueFalseTotal
if @order and ref $order[0] 2 6 8
Condition66%2/3
@order and ref $order[0]
!ll&&!rl&&r
062
MC/DC50%1/2
@order and ref $order[0]
@order ref $order[0]
Truth table66%2/3
A and B
A= @orderB= ref $order[0]
ABresult
0X0
100
111
12 if @order && ref($order[0]);
13  
14 6 my @clauses;
15 6 foreach (@order) {
16 6 foreach my $col (split(/\s*,\s*/)) {
17 10 my $dir = 'asc';
18 10 ▶ if (substr($col, 0, 1) eq '!') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($col, 0, 1) eq "!") 5 5 10
19 5 $col = substr($col, 1); # take everything after '!'
20 5 $dir = 'desc';
21 }
22  
23 # add csa prefix if necessary
24 10 ▶ $col = join('.', $self->current_source_alias, $col)
Branch: 1 branch
BranchTrueFalseTotal
if index($col, ".") == -1 10 0 10
25 if index($col, '.') == -1;
26  
27 10 push @clauses, { "-$dir" => $col };
28 }
29 }
30  
31 6 return $self->next::method(\@clauses);
32 }
33  
34 57 1;
35  
36 __END__
« Helper/Row/OnColumnChange.pm ↑ Summary Helper/Row/ProxyResultSetUpdate.pm »