File Coverage

blib/lib/WebService/Aladdin/Item/Book.pm
Criterion Covered Total %
statement 9 25 36.0
branch 0 6 0.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 12 36 33.3


line stmt bran cond sub pod time code
1             package WebService::Aladdin::Item::Book;
2              
3 2     2   10 use strict;
  2         4  
  2         66  
4 2     2   9 use warnings;
  2         3  
  2         54  
5              
6 2     2   9 use base qw(WebService::Aladdin::Item);
  2         5  
  2         11  
7              
8             __PACKAGE__->mk_accessors(qw/bookinfo/);
9              
10             sub init {
11 0     0 0   my ($self, $info) = @_;
12              
13 0           my $data;
14 0           foreach my $key (keys %{ $info }) {
  0            
15 0           my $type = $key;
16 0           $type =~ s/^aladdin://;
17 0 0         if ($type eq 'authors') {
18 0           my $author = $info->{'aladdin:authors'}->{'aladdin:author'};
19 0 0         if (ref($author) eq 'HASH') {
    0          
20 0           $data->{author} = {
21             authorid => $author->{'-authorid'},
22             authorType => $author->{'-authorType'},
23             text => $author->{'#text'},
24             desc => $author->{'-desc'},
25             };
26             }
27             elsif (ref($author) eq 'ARRAY') {
28 0           foreach my $p (@{ $info->{'aladdin:authors'}->{'aladdin:author'} }) {
  0            
29 0           unshift @{ $data->{$type} }, {
  0            
30             authorid => $p->{'-authorid'},
31             authorType => $p->{'-authorType'},
32             text => $p->{'#text'},
33             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             1;