| 1 | # ABSTRACT: DAO request role - `relationship type` | ||||||||||
| 2 | package PONAPI::DAO::Request::Role::HasRelationshipType; | ||||||||||
| 3 | |||||||||||
| 4 | 8 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 8 | has rel_type => ( | |||||||||
| 7 | is => 'ro', | ||||||||||
| 8 | isa => 'Str', | ||||||||||
| 9 | predicate => 'has_rel_type', | ||||||||||
| 10 | ); | ||||||||||
| 11 | |||||||||||
| 12 | sub _validate_rel_type { | ||||||||||
| 13 | 38 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_validate_rel_type: called CC=3 SCAR=11.0
| |||||||||||
| 14 | |||||||||||
| 15 | 38 | ▶ | return $self->_bad_request( "`relationship type` is missing" ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | unless $self->has_rel_type; | ||||||||||
| 17 | |||||||||||
| 18 | 38 | my $type = $self->type; | |||||||||
| 19 | 38 | my $rel_type = $self->rel_type; | |||||||||
| 20 | |||||||||||
| 21 | 38 | ▶ | if ( !$self->repository->has_relationship( $type, $rel_type ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 1 | return $self->_bad_request( "Types `$type` and `$rel_type` are not related", 404 ) | |||||||||
| 23 | } | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 8 | ▶ | no Moose::Role; 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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.002012 | ||||||||||
| 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 | ||||||||||