line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
942
|
use utf8; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
5
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package JSON::API::v1::Relationship; |
4
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
5
|
1
|
|
|
1
|
|
479
|
use Moose; |
|
1
|
|
|
|
|
387128
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
6269
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
85
|
use Carp qw(croak); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
58
|
|
8
|
1
|
|
|
1
|
|
5
|
use List::Util qw(any); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
213
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @CARP_NOT; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: A JSON API Relationship object according to jsonapi v1 specification |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has data => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => 'Defined', |
17
|
|
|
|
|
|
|
predicate => 'has_data', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub TO_JSON { |
21
|
4
|
|
|
4
|
0
|
114
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
4
|
100
|
100
|
|
|
112
|
if (!$self->has_data && !$self->has_links && !$self->has_meta_object) { |
|
|
|
100
|
|
|
|
|
24
|
1
|
|
|
|
|
21
|
croak("Unable to continue, you don't have data, links or meta set"); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return { |
28
|
3
|
100
|
|
|
|
119
|
$self->has_links ? (links => $self->links) : (), |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$self->has_data ? (data => $self->data) : (), |
30
|
|
|
|
|
|
|
$self->has_meta_object ? (meta => $self->meta_object) : (), |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
with qw( |
35
|
|
|
|
|
|
|
JSON::API::v1::Roles::TO_JSON |
36
|
|
|
|
|
|
|
JSON::API::v1::Roles::Links |
37
|
|
|
|
|
|
|
JSON::API::v1::Roles::MetaObject |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=encoding UTF-8 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
JSON::API::v1::Relationship - A JSON API Relationship object according to jsonapi v1 specification |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 VERSION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
version 0.002 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This module attempts to make a Moose object behave like a JSON API object as |
62
|
|
|
|
|
|
|
defined by L<jsonapi.org>. This object adheres to the v1 specification |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Wesley Schwengle <waterkip@cpan.org> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Wesley Schwengle. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is free software, licensed under: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The (three-clause) BSD License |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |