| 1 | # ABSTRACT: DAO request role - `include` | ||||||||||
| 2 | package PONAPI::DAO::Request::Role::HasInclude; | ||||||||||
| 3 | |||||||||||
| 4 | 8 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | has include => ( | ||||||||||
| 7 | traits => [ 'Array' ], | ||||||||||
| 8 | is => 'ro', | ||||||||||
| 9 | isa => 'ArrayRef', | ||||||||||
| 10 | 82 | ▶ | default => sub { +[] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 8 | handles => { | |||||||||
| 12 | "has_include" => 'count', | ||||||||||
| 13 | }, | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | sub _validate_include { | ||||||||||
| 17 | 20 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_validate_include: called CC=4 SCAR=13.9
| |||||||||||
| 18 | 20 | my $type = $self->type; | |||||||||
| 19 | |||||||||||
| 20 | 20 | ▶ | return $self->_bad_request( "`include` is missing values" ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | unless $self->has_include >= 1; | ||||||||||
| 22 | |||||||||||
| 23 | 19 | for ( @{ $self->include } ) { | |||||||||
| 24 | 24 | ▶ | $self->repository->has_relationship( $type, $_ ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | or $self->_bad_request( "Types `$type` and `$_` are not related", 404 ); | ||||||||||
| 26 | } | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 8 | ▶ | no Moose::Role; 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | __END__ | ||||||||||
| 32 | |||||||||||
| 33 | =pod | ||||||||||
| 34 | |||||||||||
| 35 | =encoding UTF-8 | ||||||||||
| 36 | |||||||||||
| 37 | =head1 NAME | ||||||||||
| 38 | |||||||||||
| 39 | PONAPI::DAO::Request::Role::HasInclude - DAO request role - `include` | ||||||||||
| 40 | |||||||||||
| 41 | =head1 VERSION | ||||||||||
| 42 | |||||||||||
| 43 | version 0.002012 | ||||||||||
| 44 | |||||||||||
| 45 | =head1 AUTHORS | ||||||||||
| 46 | |||||||||||
| 47 | =over 4 | ||||||||||
| 48 | |||||||||||
| 49 | =item * | ||||||||||
| 50 | |||||||||||
| 51 | Mickey Nasriachi <mickey@cpan.org> | ||||||||||
| 52 | |||||||||||
| 53 | =item * | ||||||||||
| 54 | |||||||||||
| 55 | Stevan Little <stevan@cpan.org> | ||||||||||
| 56 | |||||||||||
| 57 | =item * | ||||||||||
| 58 | |||||||||||
| 59 | Brian Fraser <hugmeir@cpan.org> | ||||||||||
| 60 | |||||||||||
| 61 | =back | ||||||||||
| 62 | |||||||||||
| 63 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 64 | |||||||||||
| 65 | This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser. | ||||||||||
| 66 | |||||||||||
| 67 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 68 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 69 | |||||||||||
| 70 | =cut | ||||||||||