| 1 | package Paws::API::JSONAttribute; | ||||||||||||||
| 2 | 35 | ▶ | use Moose::Role; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 34 | Moose::Util::meta_attribute_alias('JSONAttribute'); | |||||||||||||
| 4 | |||||||||||||||
| 5 | 35 | ▶ | use JSON::MaybeXS; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 35 | ▶ | use URL::Encode; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 34 | has method => (is => 'rw', isa => 'Str', required => 1); | |||||||||||||
| 9 | 34 | has decode_as => (is => 'rw', isa => 'Str', required => 1); | |||||||||||||
| 10 | |||||||||||||||
| 11 | 3 | ▶ | after 'install_accessors' => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||
| 12 | 3 | my $self = shift; | |||||||||||||
| 13 | 3 | my $realclass = $self->associated_class(); | |||||||||||||
| 14 | 3 | my $closure = $self->name; | |||||||||||||
| 15 | |||||||||||||||
| 16 | 3 | my $coderef; | |||||||||||||
| 17 | 3 | ▶ | if ($self->decode_as eq 'JSON') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 18 | 57 | ▶ | $coderef = sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | 57 | my $self = shift; | |||||||||||||
| 20 | 57 | return decode_json($self->$closure()); | |||||||||||||
| 21 | 1 | }; | |||||||||||||
| 22 | } elsif ($self->decode_as eq 'URLJSON') { | ||||||||||||||
| 23 | 0 | ▶ | $coderef = sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Subroutine
Policy: called CC=1 SCAR=1.2
| |||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||
| 25 | 0 | return decode_json(URL::Encode::url_decode($self->$closure())); | |||||||||||||
| 26 | 2 | }; | |||||||||||||
| 27 | } else { | ||||||||||||||
| 28 | 0 | die "Unrecognized JSONAttribute decode_as attribute"; | |||||||||||||
| 29 | } | ||||||||||||||
| 30 | |||||||||||||||
| 31 | 3 | $realclass->add_method( $self->method => $coderef ); | |||||||||||||
| 32 | 34 | }; | |||||||||||||
| 33 | |||||||||||||||
| 34 | 34 | 1; | |||||||||||||