File Coverage

blib/lib/PONAPI/DAO/Request/CreateRelationships.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 - create relationships
2             package PONAPI::DAO::Request::CreateRelationships;
3              
4 8     8   63 use Moose;
  8         20  
  8         67  
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 97 sub check_data_type_match { 1 } # to avoid code duplications in HasDataMethods
15              
16             sub execute {
17 18     18 0 35 my $self = shift;
18              
19 18 100       630 if ( $self->is_valid ) {
20 9         315 my @ret = $self->repository->create_relationships( %{ $self } );
  9         69  
21 4 50       67 $self->_add_success_meta(@ret)
22             if $self->_verify_update_response(@ret);
23             }
24              
25 12         70 return $self->response();
26             }
27              
28             sub _validate_rel_type {
29 15     15   28 my $self = shift;
30 15         510 my $type = $self->type;
31 15         667 my $rel_type = $self->rel_type;
32              
33 15         67 super(@_);
34              
35 15 100       599 if ( !$self->repository->has_one_to_many_relationship( $type, $rel_type ) ) {
36 1         8 $self->_bad_request( "Types `$type` and `$rel_type` are one-to-one" );
37             }
38             }
39              
40              
41             __PACKAGE__->meta->make_immutable;
42 8     8   55105 no Moose; 1;
  8         21  
  8         40  
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.002005
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