File Coverage

blib/lib/WebService/GData/Error/Entry.pm
Criterion Covered Total %
statement 20 20 100.0
branch 6 10 60.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 32 36 88.8


line stmt bran cond sub pod time code
1             package WebService::GData::Error::Entry;
2 23     23   99263 use WebService::GData 'private';
  23         47  
  23         305  
3 23     23   120 use base 'WebService::GData';
  23         39  
  23         14481  
4              
5             our $VERSION = 1.02;
6              
7             WebService::GData::install_in_package([qw(internalreason domain code location)],
8             sub {
9             my $func=shift;
10             return sub {
11 44     44   72 my $this = shift;
12 44 100       87 if(@_==1){
13 19         237 $this->{$func}=$_[0];
14             }
15 44         150 return $this->{$func};
16             };
17             });
18              
19             sub __init {
20 6     6   12 my ($this,$xmlerror) = @_;
21 6         76 $this->_parse($xmlerror);
22             }
23              
24             sub serialize {
25 2     2 1 6 my $this = shift;
26 2         4 my $xml='';
27 2 50       8 $xml.=''.$this->internalreason.'' if($this->internalreason);
28 2 50       5 $xml.=''.$this->code.'' if($this->code);
29 2 50       7 $xml.=''.$this->domain.'' if($this->domain);
30 2 50       5 $xml.="".$this->location->{content}.'' if($this->location);
31 2         5 $xml.='';
32 2         9 return $xml;
33             }
34            
35             private _parse => sub {
36             my ($this,$error) = @_;
37             if($error){
38             my ($domain) = $error=~m/(.+?)<\/domain>/;
39             my ($code) = $error=~m/(.+?)<\/code>/;
40             my $location = {};
41             ($location->{type}) = $error=~m//gmxi;
42              
43             ($location->{content}) = $error=~m/'>(.+?)<\/location>/gmxi;
44             my ($internalreason) = $error=~m/(.+?)<\/internalreason>/gmxi;
45             $this -> code($code);
46             $this -> internalreason($internalreason);
47             $this -> domain($domain);
48             $this -> location($location);
49             }
50             };
51              
52             "The earth is blue like an orange.";
53              
54             __END__