File Coverage

blib/lib/PONAPI/DAO/Request/DeleteRelationships.pm
Criterion Covered Total %
statement 19 19 100.0
branch 5 6 83.3
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 29 32 90.6


line stmt bran cond sub pod time code
1             # ABSTRACT: DAO request - delete relationships
2             package PONAPI::DAO::Request::DeleteRelationships;
3              
4 8     8   45 use Moose;
  8         87  
  8         63  
5              
6             extends 'PONAPI::DAO::Request';
7              
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     14 0 99 sub check_data_type_match { 1 } # to avoid code duplications in HasDataMethods
15              
16             sub execute {
17 15     15 0 32 my $self = shift;
18              
19 15 100       570 if ( $self->is_valid ) {
20 9         352 my @ret = $self->repository->delete_relationships( %{ $self } );
  9         70  
21              
22 6 50       76 $self->_add_success_meta(@ret)
23             if $self->_verify_update_response(@ret);
24             }
25              
26 11         78 return $self->response();
27             }
28              
29             sub _validate_rel_type {
30 14     14   31 my $self = shift;
31 14         487 my $type = $self->type;
32 14         635 my $rel_type = $self->rel_type;
33              
34 14         96 super(@_);
35              
36 14 100       562 if ( !$self->repository->has_one_to_many_relationship( $type, $rel_type ) ) {
37 1         13 $self->_bad_request( "Types `$type` and `$rel_type` are one-to-one" );
38             }
39             }
40              
41              
42             __PACKAGE__->meta->make_immutable;
43 8     8   54562 no Moose; 1;
  8         19  
  8         45  
44              
45             __END__
46              
47             =pod
48              
49             =encoding UTF-8
50              
51             =head1 NAME
52              
53             PONAPI::DAO::Request::DeleteRelationships - DAO request - delete relationships
54              
55             =head1 VERSION
56              
57             version 0.002005
58              
59             =head1 AUTHORS
60              
61             =over 4
62              
63             =item *
64              
65             Mickey Nasriachi <mickey@cpan.org>
66              
67             =item *
68              
69             Stevan Little <stevan@cpan.org>
70              
71             =item *
72              
73             Brian Fraser <hugmeir@cpan.org>
74              
75             =back
76              
77             =head1 COPYRIGHT AND LICENSE
78              
79             This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser.
80              
81             This is free software; you can redistribute it and/or modify it under
82             the same terms as the Perl 5 programming language system itself.
83              
84             =cut