File Coverage

blib/lib/PONAPI/DAO/Request/Role/HasRelationshipType.pm
Criterion Covered Total %
statement 12 12 100.0
branch 3 4 75.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 18 19 94.7


line stmt bran cond sub pod time code
1             # ABSTRACT: DAO request role - `relationship type`
2             package PONAPI::DAO::Request::Role::HasRelationshipType;
3              
4 8     8   7503 use Moose::Role;
  8         19  
  8         73  
5              
6             has rel_type => (
7             is => 'ro',
8             isa => 'Str',
9             predicate => 'has_rel_type',
10             );
11              
12             sub _validate_rel_type {
13 38     38   69 my $self = shift;
14              
15 38 50       1999 return $self->_bad_request( "`relationship type` is missing" )
16             unless $self->has_rel_type;
17              
18 38         1356 my $type = $self->type;
19 38         1734 my $rel_type = $self->rel_type;
20              
21 38 100       1351 if ( !$self->repository->has_relationship( $type, $rel_type ) ) {
22 1         12 return $self->_bad_request( "Types `$type` and `$rel_type` are not related", 404 )
23             }
24             }
25              
26 8     8   43006 no Moose::Role; 1;
  8         20  
  8         46  
27              
28             __END__
29              
30             =pod
31              
32             =encoding UTF-8
33              
34             =head1 NAME
35              
36             PONAPI::DAO::Request::Role::HasRelationshipType - DAO request role - `relationship type`
37              
38             =head1 VERSION
39              
40             version 0.002005
41              
42             =head1 AUTHORS
43              
44             =over 4
45              
46             =item *
47              
48             Mickey Nasriachi <mickey@cpan.org>
49              
50             =item *
51              
52             Stevan Little <stevan@cpan.org>
53              
54             =item *
55              
56             Brian Fraser <hugmeir@cpan.org>
57              
58             =back
59              
60             =head1 COPYRIGHT AND LICENSE
61              
62             This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser.
63              
64             This is free software; you can redistribute it and/or modify it under
65             the same terms as the Perl 5 programming language system itself.
66              
67             =cut