| 1 | package WebService::Aladdin::Item::Book; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 2 | ▶ | use base qw(WebService::Aladdin::Item); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 2 | __PACKAGE__->mk_accessors(qw/bookinfo/); | |||||||||||||
| 9 | |||||||||||||||
| 10 | 0 | ▶ | sub init { | ||||||||||||
|
Subroutine
init: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||
| 11 | 0 | my ($self, $info) = @_; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 0 | my $data; | |||||||||||||
| 14 | 0 | foreach my $key (keys %{ $info }) { | |||||||||||||
| 15 | 0 | my $type = $key; | |||||||||||||
| 16 | 0 | $type =~ s/^aladdin://; | |||||||||||||
| 17 | 0 | ▶ | if ($type eq 'authors') { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 18 | 0 | my $author = $info->{'aladdin:authors'}->{'aladdin:author'}; | |||||||||||||
| 19 | 0 | ▶ | if (ref($author) eq 'HASH') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 20 | $data->{author} = { | ||||||||||||||
| 21 | authorid => $author->{'-authorid'}, | ||||||||||||||
| 22 | authorType => $author->{'-authorType'}, | ||||||||||||||
| 23 | text => $author->{'#text'}, | ||||||||||||||
| 24 | 0 | desc => $author->{'-desc'}, | |||||||||||||
| 25 | }; | ||||||||||||||
| 26 | } | ||||||||||||||
| 27 | elsif (ref($author) eq 'ARRAY') { | ||||||||||||||
| 28 | 0 | foreach my $p (@{ $info->{'aladdin:authors'}->{'aladdin:author'} }) { | |||||||||||||
| 29 | 0 | unshift @{ $data->{$type} }, { | |||||||||||||
| 30 | authorid => $p->{'-authorid'}, | ||||||||||||||
| 31 | authorType => $p->{'-authorType'}, | ||||||||||||||
| 32 | text => $p->{'#text'}, | ||||||||||||||
| 33 | 0 | desc => $p->{'-desc'}, | |||||||||||||
| 34 | }; | ||||||||||||||
| 35 | } | ||||||||||||||
| 36 | } | ||||||||||||||
| 37 | } | ||||||||||||||
| 38 | else { | ||||||||||||||
| 39 | 0 | $data->{$type} = $info->{$key}; | |||||||||||||
| 40 | } | ||||||||||||||
| 41 | } | ||||||||||||||
| 42 | 0 | $self->bookinfo($data); | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | |||||||||||||||
| 45 | 2 | 1; | |||||||||||||