| 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
| |||||||||||
| 18 | 0 | ▶ | if(ref $args[0] eq 'ARRAY') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 35 | 0 | $plus_select_args{'-as'} = delete $args{'-as'}; | |||||||||
| 36 | } | ||||||||||
| 37 | 0 | ▶ | if(exists $args{'-name'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | push @plus_as_args => delete $args{'-name'}; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | if(scalar keys %args != 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||