line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1766
|
use utf8; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
11
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package JSON::API::v1::Error; |
4
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
5
|
2
|
|
|
2
|
|
534
|
use Moose; |
|
2
|
|
|
|
|
385043
|
|
|
2
|
|
|
|
|
13
|
|
6
|
2
|
|
|
2
|
|
10715
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: A JSON API object according to jsonapi.org v1 specification |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has id => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => 'Str', |
13
|
|
|
|
|
|
|
predicate => 'has_id', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has status => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => 'Int', # TODO: HTTP::Status type |
19
|
|
|
|
|
|
|
predicate => 'has_status', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has code => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => 'Str', |
25
|
|
|
|
|
|
|
predicate => 'has_code', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has title => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => 'Str', |
31
|
|
|
|
|
|
|
predicate => 'has_title', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has detail => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => 'Defined', |
37
|
|
|
|
|
|
|
predicate => 'has_detail', |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has source => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
isa => 'Defined', |
43
|
|
|
|
|
|
|
predicate => 'has_source', |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub TO_JSON { |
47
|
3
|
|
|
3
|
0
|
37
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
6
|
my %rv; |
50
|
3
|
|
|
|
|
11
|
foreach (qw(id status code title detail source links)) { |
51
|
21
|
|
|
|
|
35
|
my $has = 'has_' . $_; |
52
|
21
|
100
|
|
|
|
539
|
if ($self->$has) { |
53
|
8
|
|
|
|
|
176
|
$rv{$_} = $self->$_; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
3
|
100
|
|
|
|
93
|
$rv{meta} = $self->meta_object if $self->has_meta_object; |
57
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
30
|
return \%rv; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
with qw( |
62
|
|
|
|
|
|
|
JSON::API::v1::Roles::TO_JSON |
63
|
|
|
|
|
|
|
JSON::API::v1::Roles::MetaObject |
64
|
|
|
|
|
|
|
JSON::API::v1::Roles::Links |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
JSON::API::v1::Error - A JSON API object according to jsonapi.org v1 specification |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
version 0.002 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SYNOPSIS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 DESCRIPTION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This module attempts to make a Moose object behave like a JSON API object as |
89
|
|
|
|
|
|
|
defined by L<jsonapi.org>. This object adheres to the v1 specification |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 METHODS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Wesley Schwengle <waterkip@cpan.org> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Wesley Schwengle. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This is free software, licensed under: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The (three-clause) BSD License |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |