Smooth/Helper/ResultSet/Shortcut/AddColumn.pm

filter: Statementstmt 54.0% 20 / 37 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 45.6% 26 / 57 CC 7 SCAR 34.2
CC
7
Cov
41%
add_column
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 30.6
« Smooth/Lookup/ident.pm ↑ Summary Smooth/Functions.pm »
1 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DBIx::Class::Smooth::Helper::ResultSet::Shortcut::AddColumn;
6  
7 # ABSTRACT: Short intro
8 1 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 1 our $VERSION = '0.0108';
10  
11 1 ▶use parent 'DBIx::Class::Helper::ResultSet::Shortcut::AddColumns';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use experimental qw/signatures postderef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 0 ▶sub add_column($self, @args) {
Subroutine add_column: not called CC=7 SCAR=40.3
Pod undocumented
16 # If given single argument, fall back to DBIx::Class::Helper::ResultSet::Shortcut::AddColumns
17 0 ▶ if(scalar @args == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 1) 0 0 0
18 0 ▶ if(ref $args[0] eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args[0] eq 'ARRAY') { } 0 0 0
19 0 return $self->add_columns($args[0]);
20 }
21 else {
22 0 return $self->add_columns([ $args[0] ]);
23 }
24 }
25 # From here on we expect to expand @args to a hash
26 0 ▶ if(scalar @args % 2 == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args % 2 == 1) 0 0 0
27 0 confess "add_column given an un-even number of arguments"
28 }
29 0 my %args = @args;
30  
31 0 my %plus_select_args = ();
32 0 my @plus_as_args = ();
33  
34 0 ▶ if(exists $args{'-as'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"-as"}) 0 0 0
35 0 $plus_select_args{'-as'} = delete $args{'-as'};
36 }
37 0 ▶ if(exists $args{'-name'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"-name"}) 0 0 0
38 0 push @plus_as_args => delete $args{'-name'};
39 }
40  
41 0 ▶ if(scalar keys %args != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %args != 1) 0 0 0
42 0 confess sprintf("add_column has an unexpected number of keys (%d) before search: %s", scalar(keys %args), join(', ', keys %args));
43 }
44  
45 0 %plus_select_args = (%plus_select_args, %args);
46 0 return $self->search(undef, {
47 '+select' => [\%plus_select_args],
48 '+as' => \@plus_as_args,
49 });
50 }
51  
52 1 1;
53  
54 __END__
« Smooth/Lookup/ident.pm ↑ Summary Smooth/Functions.pm »