PONAPI/DAO/Request/CreateRelationships.pm

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