line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Paws::API::JSONAttribute; |
2
|
22
|
|
|
22
|
|
158
|
use Moose::Role; |
|
22
|
|
|
|
|
66
|
|
|
22
|
|
|
|
|
192
|
|
3
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('JSONAttribute'); |
4
|
|
|
|
|
|
|
|
5
|
22
|
|
|
22
|
|
135836
|
use JSON::MaybeXS; |
|
22
|
|
|
|
|
129396
|
|
|
22
|
|
|
|
|
1379
|
|
6
|
22
|
|
|
22
|
|
9398
|
use URL::Encode; |
|
22
|
|
|
|
|
27636
|
|
|
22
|
|
|
|
|
4453
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has method => (is => 'rw', isa => 'Str', required => 1); |
9
|
|
|
|
|
|
|
has decode_as => (is => 'rw', isa => 'Str', required => 1); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
after 'install_accessors' => sub { |
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
my $realclass = $self->associated_class(); |
14
|
|
|
|
|
|
|
my $closure = $self->name; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $coderef; |
17
|
|
|
|
|
|
|
if ($self->decode_as eq 'JSON') { |
18
|
|
|
|
|
|
|
$coderef = sub { |
19
|
57
|
|
|
57
|
|
30974
|
my $self = shift; |
20
|
57
|
|
|
|
|
1795
|
return decode_json($self->$closure()); |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
} elsif ($self->decode_as eq 'URLJSON') { |
23
|
|
|
|
|
|
|
$coderef = sub { |
24
|
14
|
|
|
14
|
|
4835
|
my $self = shift; |
|
|
|
|
14
|
|
|
|
25
|
14
|
|
|
|
|
416
|
return decode_json(URL::Encode::url_decode($self->$closure())); |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
} else { |
28
|
|
|
|
|
|
|
die "Unrecognized JSONAttribute decode_as attribute"; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$realclass->add_method( $self->method => $coderef ); |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |