PONAPI/DAO/Request/CreateRelationships.pm

filter: Statementstmt 100% 23 / 23 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 91.6% 33 / 36 CC 4 SCAR 6.9
CC
4
Cov
97%
execute
3.0
_validate_rel_type
2.0
BEGIN
1.0
CRAP 2.0
« PONAPI/CLI/Command/manual.pm ↑ Summary PONAPI/DAO/Request/DeleteRelationships.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 15 ▶ my $self = shift;
Subroutine _validate_rel_type: called CC=2 SCAR=6.9
30 15 my $type = $self->type;
31 15 my $rel_type = $self->rel_type;
32  
33 15 super(@_);
34  
35 15 ▶ if ( !$self->repository->has_one_to_many_relationship( $type, $rel_type ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->repository->has_one_to_many_relationship($type, $rel_type)) 1 14 15
36 1 $self->_bad_request( "Types `$type` and `$rel_type` are one-to-one" );
37 }
38 }
39  
40  
41 8 __PACKAGE__->meta->make_immutable;
42 8 ▶no Moose; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 __END__
45  
46 =pod
47  
48 =encoding UTF-8
49  
50 =head1 NAME
51  
52 PONAPI::DAO::Request::CreateRelationships - DAO request - create relationships
53  
54 =head1 VERSION
55  
56 version 0.002012
57  
58 =head1 AUTHORS
59  
60 =over 4
61  
62 =item *
63  
64 Mickey Nasriachi <mickey@cpan.org>
65  
66 =item *
67  
68 Stevan Little <stevan@cpan.org>
69  
70 =item *
71  
72 Brian Fraser <hugmeir@cpan.org>
73  
74 =back
75  
76 =head1 COPYRIGHT AND LICENSE
77  
78 This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser.
79  
80 This is free software; you can redistribute it and/or modify it under
81 the same terms as the Perl 5 programming language system itself.
82  
83 =cut
« PONAPI/CLI/Command/manual.pm ↑ Summary PONAPI/DAO/Request/DeleteRelationships.pm »