| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Regru::API::Role::Serializer; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: something that can (de)serialize |
|
4
|
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
26280
|
use strict; |
|
|
14
|
|
|
|
|
32
|
|
|
|
14
|
|
|
|
|
410
|
|
|
6
|
14
|
|
|
14
|
|
74
|
use warnings; |
|
|
14
|
|
|
|
|
26
|
|
|
|
14
|
|
|
|
|
336
|
|
|
7
|
14
|
|
|
14
|
|
74
|
use Moo::Role; |
|
|
14
|
|
|
|
|
25
|
|
|
|
14
|
|
|
|
|
75
|
|
|
8
|
14
|
|
|
14
|
|
13088
|
use JSON; |
|
|
14
|
|
|
|
|
132367
|
|
|
|
14
|
|
|
|
|
200
|
|
|
9
|
14
|
|
|
14
|
|
1977
|
use Carp; |
|
|
14
|
|
|
|
|
97
|
|
|
|
14
|
|
|
|
|
716
|
|
|
10
|
14
|
|
|
14
|
|
565
|
use namespace::autoclean; |
|
|
14
|
|
|
|
|
11776
|
|
|
|
14
|
|
|
|
|
91
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.051'; # VERSION |
|
13
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has serializer => ( |
|
16
|
|
|
|
|
|
|
is => 'rw', |
|
17
|
|
|
|
|
|
|
isa => sub { |
|
18
|
|
|
|
|
|
|
croak "$_[0] is not a JSON instance" unless ref($_[0]) =~ m/JSON/; |
|
19
|
|
|
|
|
|
|
croak "$_[0] can not decode" unless $_[0]->can('decode'); |
|
20
|
|
|
|
|
|
|
croak "$_[0] can not encode" unless $_[0]->can('encode'); |
|
21
|
|
|
|
|
|
|
}, |
|
22
|
|
|
|
|
|
|
lazy => 1, |
|
23
|
|
|
|
|
|
|
default => sub { JSON->new->utf8 }, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; # End of Regru::API::Role::Serializer |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__END__ |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=encoding UTF-8 |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Regru::API::Role::Serializer - something that can (de)serialize |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 VERSION |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
version 0.051 |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package Regru::API::Client; |
|
45
|
|
|
|
|
|
|
... |
|
46
|
|
|
|
|
|
|
with 'Regru::API::Role::Serializer'; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$str = $self->serializer->encode({ answer => 42, foo => [qw(bar baz quux)] }); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Any class or role that consumes this one will able to (de)serialize JSON. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 serializer |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Returns an L<JSON> instance with B<utf8> option enabled. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
L<Regru::API> |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L<Regru::API::Role::Client> |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L<JSON> |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 BUGS |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
|
71
|
|
|
|
|
|
|
L<https://github.com/regru/regru-api-perl/issues> |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
|
74
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
|
75
|
|
|
|
|
|
|
feature. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHORS |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Polina Shubina <shubina@reg.ru> |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Anton Gerasimov <a.gerasimov@reg.ru> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This software is copyright (c) 2013 by REG.RU LLC. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
96
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |