line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebAPI::DBIC::Resource::Role::Item; |
2
|
|
|
|
|
|
|
$WebAPI::DBIC::Resource::Role::Item::VERSION = '0.004001'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
26192335
|
use Moo::Role; |
|
2
|
|
|
|
|
53610
|
|
|
2
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
requires 'render_item_as_plain_hash'; |
8
|
|
|
|
|
|
|
requires 'id_unique_constraint_name'; |
9
|
|
|
|
|
|
|
requires 'encode_json'; |
10
|
|
|
|
|
|
|
requires 'set'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has id => ( # array of 1 or more key values from url path |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
#isa => array ref |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
builder => '_build_id' |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _build_id { |
21
|
|
|
|
|
|
|
# we could possibly try to extract an id from item() if that's set |
22
|
|
|
|
|
|
|
# (but we'd need to avoid infinite recursion) |
23
|
0
|
|
|
0
|
|
|
die sprintf "No id provided for %s", ref shift; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has item => ( |
27
|
|
|
|
|
|
|
is => 'rw', # XXX |
28
|
|
|
|
|
|
|
lazy => 1, |
29
|
|
|
|
|
|
|
builder => '_build_item' |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _build_item { |
33
|
0
|
|
|
0
|
|
|
my $self = shift; |
34
|
0
|
|
|
|
|
|
return $self->set->find( @{ $self->id }, { key => $self->id_unique_constraint_name } ); |
|
0
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has content_types_provided => ( |
38
|
|
|
|
|
|
|
is => 'lazy', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _build_content_types_provided { |
42
|
0
|
|
|
0
|
|
|
return [ { 'application/vnd.wapid+json' => 'to_json_as_plain' } ] |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
|
sub to_json_as_plain { return $_[0]->encode_json($_[0]->render_item_as_plain_hash($_[0]->item)) } |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
0
|
|
sub resource_exists { return !! $_[0]->item } |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
0
|
|
sub allowed_methods { return [ qw(GET HEAD) ] } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding UTF-8 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
WebAPI::DBIC::Resource::Role::Item |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 VERSION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
version 0.004001 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Handles GET and HEAD requests for requests representing individual resources, |
71
|
|
|
|
|
|
|
e.g. a single row of a database table. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
WebAPI::DBIC::Resource::Role::Item - methods related to handling requests for item resources |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Tim Bunce <Tim.Bunce@pobox.com> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Tim Bunce. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
86
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |