line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1096
|
use utf8; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
6
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package JSON::API::v1::Relationship; |
4
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
5
|
1
|
|
|
1
|
|
593
|
use Moose; |
|
1
|
|
|
|
|
475724
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
7790
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
7
|
1
|
|
|
1
|
|
100
|
use Carp qw(croak); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
60
|
|
8
|
1
|
|
|
1
|
|
7
|
use List::Util qw(any); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
253
|
|
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
|
130
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
4
|
100
|
100
|
|
|
143
|
if (!$self->has_data && !$self->has_links && !$self->has_meta_object) { |
|
|
|
100
|
|
|
|
|
24
|
1
|
|
|
|
|
22
|
croak("Unable to continue, you don't have data, links or meta set"); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return { |
28
|
3
|
100
|
|
|
|
98
|
$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.001 |
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 |