PONAPI/DAO/Request/DeleteRelationships.pm

filter: Statementstmt 100% 23 / 23 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 87.5% 35 / 40 CC 6 SCAR 10.4
CC
6
Cov
91%
_validate_rel_type
4.1
execute
3.0
BEGIN
1.0
CRAP 2.8
« PONAPI/DAO/Request.pm ↑ Summary PONAPI/DAO/Request/CreateRelationships.pm »
1 # ABSTRACT: DAO request - delete relationships
2 package PONAPI::DAO::Request::DeleteRelationships;
3  
4 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 extends 'PONAPI::DAO::Request';
7  
8 8 with 'PONAPI::DAO::Request::Role::UpdateLike',
9 'PONAPI::DAO::Request::Role::HasDataBulk',
10 'PONAPI::DAO::Request::Role::HasDataMethods',
11 'PONAPI::DAO::Request::Role::HasID',
12 'PONAPI::DAO::Request::Role::HasRelationshipType';
13  
14 14 ▶sub check_data_type_match { 1 } # to avoid code duplications in HasDataMethods
Subroutine check_data_type_match: called CC=1 SCAR=0.0
Pod undocumented
15  
16 sub execute {
17 15 ▶ my $self = shift;
Subroutine execute: called CC=3 SCAR=11.0
Pod undocumented
18  
19 15 ▶ if ( $self->is_valid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_valid) 9 6 15
20 9 my @ret = $self->repository->delete_relationships( %{ $self } );
21  
22 6 ▶ $self->_add_success_meta(@ret)
Branch: 1 branch
BranchTrueFalseTotal
if $self->_verify_update_response(@ret) 5 0 5
23 if $self->_verify_update_response(@ret);
24 }
25  
26 11 return $self->response();
27 }
28  
29 sub _validate_rel_type {
30 14 ▶ my ( $self, $args ) = @_;
Subroutine _validate_rel_type: called CC=4 SCAR=14.0
31  
32 14 ▶ return $self->_bad_request( "`relationship type` is missing for this request" )
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_rel_type 0 14 14
33 unless $self->has_rel_type;
34  
35 14 my $type = $self->type;
36 14 my $rel_type = $self->rel_type;
37  
38 14 ▶ return $self->_bad_request( "Types `$type` and `$rel_type` are not related", 404 )
Branch: 1 branch
BranchTrueFalseTotal
unless $self->repository->has_relationship($type, $rel_type) 0 14 14
39 unless $self->repository->has_relationship( $type, $rel_type );
40  
41 14 ▶ return $self->_bad_request( "Types `$type` and `$rel_type` are one-to-one" )
Branch: 1 branch
BranchTrueFalseTotal
unless $self->repository->has_one_to_many_relationship($type, $rel_type) 1 13 14
42 unless $self->repository->has_one_to_many_relationship( $type, $rel_type );
43 }
44  
45  
46 8 __PACKAGE__->meta->make_immutable;
47 8 ▶no Moose; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 __END__
50  
51 =pod
52  
53 =encoding UTF-8
54  
55 =head1 NAME
56  
57 PONAPI::DAO::Request::DeleteRelationships - DAO request - delete relationships
58  
59 =head1 VERSION
60  
61 version 0.003002
62  
63 =head1 AUTHORS
64  
65 =over 4
66  
67 =item *
68  
69 Mickey Nasriachi <mickey@cpan.org>
70  
71 =item *
72  
73 Stevan Little <stevan@cpan.org>
74  
75 =item *
76  
77 Brian Fraser <hugmeir@cpan.org>
78  
79 =back
80  
81 =head1 COPYRIGHT AND LICENSE
82  
83 This software is copyright (c) 2017 by Mickey Nasriachi, Stevan Little, Brian Fraser.
84  
85 This is free software; you can redistribute it and/or modify it under
86 the same terms as the Perl 5 programming language system itself.
87  
88 =cut
« PONAPI/DAO/Request.pm ↑ Summary PONAPI/DAO/Request/CreateRelationships.pm »