| 1 | package WebService::Google::Closure::Response; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use MooseX::Types::Moose qw( ArrayRef Str Int ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use WebService::Google::Closure::Types qw( ArrayRefOfWarnings ArrayRefOfErrors Stats ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | has format => ( | ||||||||||
| 10 | is => 'ro', | ||||||||||
| 11 | isa => Str, | ||||||||||
| 12 | 1 | ▶ | trigger => sub { my $self = shift; die "Bad format - only json" unless $self->format eq 'json' }, | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||
| 13 | 3 | ); | |||||||||
| 14 | |||||||||||
| 15 | 3 | has content => ( | |||||||||
| 16 | is => 'ro', | ||||||||||
| 17 | isa => Str, | ||||||||||
| 18 | trigger => \&_set_content, | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 3 | has code => ( | |||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | isa => Str, | ||||||||||
| 24 | predicate => 'has_code', | ||||||||||
| 25 | writer => '_set_compiledCode', | ||||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | 3 | has warnings => ( | |||||||||
| 29 | is => 'ro', | ||||||||||
| 30 | isa => ArrayRefOfWarnings, | ||||||||||
| 31 | init_arg => undef, | ||||||||||
| 32 | predicate => 'has_warnings', | ||||||||||
| 33 | writer => '_set_warnings', | ||||||||||
| 34 | coerce => 1, | ||||||||||
| 35 | ); | ||||||||||
| 36 | |||||||||||
| 37 | 3 | has errors => ( | |||||||||
| 38 | is => 'ro', | ||||||||||
| 39 | isa => ArrayRefOfErrors, | ||||||||||
| 40 | init_arg => undef, | ||||||||||
| 41 | predicate => 'has_errors', | ||||||||||
| 42 | writer => '_set_errors', | ||||||||||
| 43 | coerce => 1, | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | 3 | has stats => ( | |||||||||
| 47 | is => 'ro', | ||||||||||
| 48 | isa => Stats, | ||||||||||
| 49 | init_arg => undef, | ||||||||||
| 50 | predicate => 'has_stats', | ||||||||||
| 51 | writer => '_set_statistics', | ||||||||||
| 52 | coerce => 1, | ||||||||||
| 53 | ); | ||||||||||
| 54 | |||||||||||
| 55 | 3 | has is_success => ( | |||||||||
| 56 | is => 'ro', | ||||||||||
| 57 | lazy_build => 1, | ||||||||||
| 58 | ); | ||||||||||
| 59 | |||||||||||
| 60 | 1 | ▶ | sub _build_is_success { | ||||||||
|
Subroutine
_build_is_success: called CC=2 SCAR=7.6
| |||||||||||
| 61 | 1 | my $self = shift; | |||||||||
| 62 | 1 | ▶ | if ( $self->has_errors ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | return 0; | |||||||||
| 64 | } | ||||||||||
| 65 | 1 | return 1; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 1 | ▶ | sub _set_content { | ||||||||
|
Subroutine
_set_content: called CC=3 SCAR=11.0
| |||||||||||
| 69 | 1 | my $self = shift; | |||||||||
| 70 | |||||||||||
| 71 | 1 | my $json = JSON->new(); | |||||||||
| 72 | 1 | my $content = $json->decode( $self->content ); | |||||||||
| 73 | 1 | foreach my $key ( keys %{ $content } ) { | |||||||||
| 74 | 2 | ▶ | next unless $content->{ $key }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 2 | my $set = '_set_' . $key; | |||||||||
| 76 | 2 | $self->$set( $content->{ $key } ); | |||||||||
| 77 | } | ||||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | # bail out on server errors | ||||||||||
| 81 | 0 | ▶ | sub _set_serverErrors { | ||||||||
|
Subroutine
_set_serverErrors: not called CC=2 SCAR=17.9
| |||||||||||
| 82 | 0 | my ($self, $err) = @_; | |||||||||
| 83 | |||||||||||
| 84 | 0 | my $text = ''; | |||||||||
| 85 | 0 | foreach my $e ( @{ $err } ) { | |||||||||
| 86 | 0 | $text .= $e->{ error }; | |||||||||
| 87 | } | ||||||||||
| 88 | 0 | die $text; | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | 3 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 92 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||
| 93 | 3 | 1; | |||||||||
| 94 | |||||||||||
| 95 | __END__ | ||||||||||