ResultSet/Dezi.pm

filter: Statementstmt 33.3% 8 / 24 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 30.5% 11 / 36 CC 5 SCAR 30.8
CC
5
Cov
25%
search_dezi
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 21.7
↑ Summary Dezi.pm »
1 package DBIx::Class::IndexSearch::ResultSet::Dezi;
2  
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 extends 'DBIx::Class::ResultSet';
5  
6 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 =head1 SUBROUTINES/METHODS
8  
9 =head2 search_dezi ( $self, \%search, \%attributes )
10  
11 Searches the Dezi webservice for results and maps the results over
12 to inflate objects.
13  
14 =cut
15 0 ▶sub search_dezi {
Subroutine search_dezi: not called CC=5 SCAR=34.0
Pod documented
16 0 my ( $self, $search, $attributes ) = @_;
17  
18 0 my $result_class = $self->result_class;
19  
20 0 ▶ my @search = ref $search eq 'ARRAY' ? @{$search} :
Branch: 1 branch
BranchTrueFalseTotal
ref $search eq 'HASH' ? : 0 0 0
21 0 ▶ ref $search eq 'HASH' ? %{$search} :
Branch: 1 branch
BranchTrueFalseTotal
ref $search eq 'ARRAY' ? : 0 0 0
22 croak 'search_dezi only accepts an arrayref or a hashref';
23  
24 0 my $map_field = $result_class->map_to;
25 0 my @ids;
26  
27 0 ▶ while ( my $column = shift @search ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $column = shift @search) 0 0 0
28 0 my $value = shift @search;
29 0 ▶ if ( $result_class->index_key_exists($column) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result_class->index_key_exists($column)) 0 0 0
30 0 my $dezi = $result_class->webservice;
31 0 my $response = $dezi->search( q => $value );
32  
33 @ids = map {
34 0 $_->{$map_field}->[0]
35 }
36 0 @{$response->results};
37 }
38 }
39  
40 0 return $self->search({ $map_field => \@ids });
41 }
42  
43 2 1;
↑ Summary Dezi.pm »