File Coverage

blib/lib/WebAPI/DBIC/Resource/JSONAPI/Role/Set.pm
Criterion Covered Total %
statement 6 8 75.0
branch n/a
condition n/a
subroutine 2 3 66.6
pod 0 1 0.0
total 8 12 66.6


line stmt bran cond sub pod time code
1             package WebAPI::DBIC::Resource::JSONAPI::Role::Set;
2             $WebAPI::DBIC::Resource::JSONAPI::Role::Set::VERSION = '0.004001';
3              
4 2     2   40271317 use Moo::Role;
  2         43461  
  2         10  
5              
6 2     2   606 use Carp qw(confess);
  2         3  
  2         469  
7              
8             requires '_build_content_types_provided';
9             requires 'encode_json';
10             requires 'set';
11             requires 'render_jsonapi_response';
12             requires 'jsonapi_type';
13              
14              
15             around '_build_content_types_provided' => sub {
16             my $orig = shift;
17             my $self = shift;
18             my $types = $self->$orig();
19             unshift @$types, { 'application/vnd.api+json' => 'to_json_as_jsonapi' };
20             return $types;
21             };
22              
23              
24             sub to_json_as_jsonapi {
25 0     0 0   my $self = shift;
26 0           return $self->encode_json( $self->render_jsonapi_response() );
27             }
28              
29              
30             1;
31              
32             __END__
33              
34             =pod
35              
36             =encoding UTF-8
37              
38             =head1 NAME
39              
40             WebAPI::DBIC::Resource::JSONAPI::Role::Set
41              
42             =head1 VERSION
43              
44             version 0.004001
45              
46             =head1 DESCRIPTION
47              
48             Handles GET and HEAD requests for requests representing set resources, e.g.
49             the rows of a database table.
50              
51             Supports the C<application/vnd.api+json> content type.
52              
53             =head1 NAME
54              
55             WebAPI::DBIC::Resource::JSONAPI::Role::Set - add JSON API content type support for set resources
56              
57             =head1 AUTHOR
58              
59             Tim Bunce <Tim.Bunce@pobox.com>
60              
61             =head1 COPYRIGHT AND LICENSE
62              
63             This software is copyright (c) 2015 by Tim Bunce.
64              
65             This is free software; you can redistribute it and/or modify it under
66             the same terms as the Perl 5 programming language system itself.
67              
68             =cut