File Coverage

blib/lib/PONAPI/DAO/Request/RetrieveByRelationship.pm
Criterion Covered Total %
statement 16 16 100.0
branch 5 6 83.3
condition 2 3 66.6
subroutine 3 3 100.0
pod 0 1 0.0
total 26 29 89.6


line stmt bran cond sub pod time code
1             # ABSTRACT: DAO request - retrieve by relationship
2             package PONAPI::DAO::Request::RetrieveByRelationship;
3              
4 8     8   64 use Moose;
  8         54  
  8         69  
5              
6             extends 'PONAPI::DAO::Request';
7              
8             with 'PONAPI::DAO::Request::Role::HasFields',
9             'PONAPI::DAO::Request::Role::HasFilter',
10             'PONAPI::DAO::Request::Role::HasInclude',
11             'PONAPI::DAO::Request::Role::HasPage',
12             'PONAPI::DAO::Request::Role::HasSort',
13             'PONAPI::DAO::Request::Role::HasID',
14             'PONAPI::DAO::Request::Role::HasRelationshipType';
15              
16             sub execute {
17 15     15 0 41 my $self = shift;
18              
19 15 100       476 if ( $self->is_valid ) {
20 10         268 my $repo = $self->repository;
21 10         274 my $document = $self->document;
22 10         270 my $one_to_many = $repo->has_one_to_many_relationship($self->type, $self->rel_type);
23              
24 10 100       60 $document->convert_to_collection if $one_to_many;
25              
26 10         206 $repo->retrieve_by_relationship( %{ $self } );
  10         82  
27              
28 7 50 66     923 $document->add_null_resource
29             unless $one_to_many or $document->has_resource_builders;
30             }
31              
32 12         89 return $self->response();
33             }
34              
35             __PACKAGE__->meta->make_immutable;
36 8     8   56582 no Moose; 1;
  8         25  
  8         54  
37              
38             __END__
39              
40             =pod
41              
42             =encoding UTF-8
43              
44             =head1 NAME
45              
46             PONAPI::DAO::Request::RetrieveByRelationship - DAO request - retrieve by relationship
47              
48             =head1 VERSION
49              
50             version 0.003003
51              
52             =head1 AUTHORS
53              
54             =over 4
55              
56             =item *
57              
58             Mickey Nasriachi <mickey@cpan.org>
59              
60             =item *
61              
62             Stevan Little <stevan@cpan.org>
63              
64             =item *
65              
66             Brian Fraser <hugmeir@cpan.org>
67              
68             =back
69              
70             =head1 COPYRIGHT AND LICENSE
71              
72             This software is copyright (c) 2019 by Mickey Nasriachi, Stevan Little, Brian Fraser.
73              
74             This is free software; you can redistribute it and/or modify it under
75             the same terms as the Perl 5 programming language system itself.
76              
77             =cut