PONAPI/DAO/Request/Role/HasInclude.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 26 / 26 CC 5 SCAR 12.5
CC
5
Cov
100%
_validate_include
5.0
BEGIN
1.0
__ANON__
1.0
CRAP 3.5
« PONAPI/DAO/Request/RetrieveRelationships.pm ↑ Summary PONAPI/DAO/Request/Role/UpdateLike.pm »
1 # ABSTRACT: DAO request role - `include`
2 package PONAPI::DAO::Request::Role::HasInclude;
3  
4 8 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 has include => (
7 traits => [ 'Array' ],
8 is => 'ro',
9 isa => 'ArrayRef',
10 82 ▶ default => sub { +[] },
Subroutine __ANON__: called CC=1 SCAR=0.0
11 8 handles => {
12 "has_include" => 'count',
13 },
14 );
15  
16 sub _validate_include {
17 97 ▶ my ( $self, $args ) = @_;
Subroutine _validate_include: called CC=5 SCAR=16.1
18  
19 97 ▶ return unless defined $args->{include};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args->{"include"} 77 20 97
20  
21 20 ▶ return $self->_bad_request( "`include` is missing values" )
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_include >= 1 1 19 20
22 unless $self->has_include >= 1;
23  
24 19 my $type = $self->type;
25  
26 19 for ( @{ $self->include } ) {
27 24 ▶ $self->repository->has_relationship( $type, $_ )
Branch: 1 branch
BranchTrueFalseTotal
$self->repository->has_relationship($type, $_) or $self->_bad_request("Types `$type` and `$_` are not related", 404) 5 19 24
28 or $self->_bad_request( "Types `$type` and `$_` are not related", 404 );
29 }
30 }
31  
32 8 ▶no Moose::Role; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 __END__
35  
36 =pod
37  
38 =encoding UTF-8
39  
40 =head1 NAME
41  
42 PONAPI::DAO::Request::Role::HasInclude - DAO request role - `include`
43  
44 =head1 VERSION
45  
46 version 0.003002
47  
48 =head1 AUTHORS
49  
50 =over 4
51  
52 =item *
53  
54 Mickey Nasriachi <mickey@cpan.org>
55  
56 =item *
57  
58 Stevan Little <stevan@cpan.org>
59  
60 =item *
61  
62 Brian Fraser <hugmeir@cpan.org>
63  
64 =back
65  
66 =head1 COPYRIGHT AND LICENSE
67  
68 This software is copyright (c) 2017 by Mickey Nasriachi, Stevan Little, Brian Fraser.
69  
70 This is free software; you can redistribute it and/or modify it under
71 the same terms as the Perl 5 programming language system itself.
72  
73 =cut
« PONAPI/DAO/Request/RetrieveRelationships.pm ↑ Summary PONAPI/DAO/Request/Role/UpdateLike.pm »