File Coverage

blib/lib/WebAPI/DBIC/Resource/HAL/Role/Item.pm
Criterion Covered Total %
statement 3 4 75.0
branch n/a
condition n/a
subroutine 1 2 50.0
pod 0 1 0.0
total 4 7 57.1


line stmt bran cond sub pod time code
1             package WebAPI::DBIC::Resource::HAL::Role::Item;
2             $WebAPI::DBIC::Resource::HAL::Role::Item::VERSION = '0.003002';
3              
4 2     2   22052360 use Moo::Role;
  2         45603  
  2         15  
5              
6              
7             requires '_build_content_types_provided';
8             requires 'render_item_as_hal_hash';
9             requires 'encode_json';
10             requires 'item';
11              
12              
13             around '_build_content_types_provided' => sub {
14             my $orig = shift;
15             my $self = shift;
16             my $types = $self->$orig();
17             unshift @$types, { 'application/hal+json' => 'to_json_as_hal' };
18             return $types;
19             };
20              
21 0     0 0   sub to_json_as_hal { return $_[0]->encode_json($_[0]->render_item_as_hal_hash($_[0]->item)) }
22              
23             1;
24              
25             __END__
26              
27             =pod
28              
29             =encoding UTF-8
30              
31             =head1 NAME
32              
33             WebAPI::DBIC::Resource::HAL::Role::Item
34              
35             =head1 VERSION
36              
37             version 0.003002
38              
39             =head1 DESCRIPTION
40              
41             Provides methods to support the C<application/hal+json> media type
42             for GET and HEAD requests for requests representing individual resources,
43             e.g. a single row of a database table.
44              
45             =head1 NAME
46              
47             WebAPI::DBIC::Resource::HAL::Role::Item - methods related to handling HAL requests for item resources
48              
49             =head1 AUTHOR
50              
51             Tim Bunce <Tim.Bunce@pobox.com>
52              
53             =head1 COPYRIGHT AND LICENSE
54              
55             This software is copyright (c) 2015 by Tim Bunce.
56              
57             This is free software; you can redistribute it and/or modify it under
58             the same terms as the Perl 5 programming language system itself.
59              
60             =cut