File Coverage

blib/lib/WWW/Google/Contacts/InternalTypes.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package WWW::Google::Contacts::InternalTypes;
2             {
3             $WWW::Google::Contacts::InternalTypes::VERSION = '0.39';
4             }
5              
6 20         195 use MooseX::Types -declare => [
7             qw(
8             XmlBool
9             Rel
10             When
11             Where
12             Method
13             Country
14             YomiStr
15             )
16 20     20   113 ];
  20         45  
17              
18 20     20   151801 use MooseX::Types::Moose qw(Str Bool HashRef CodeRef Any);
  20         50  
  20         172  
19              
20             subtype Method, as CodeRef;
21              
22             coerce Method, from Any, via {
23             sub { return $_ }
24             };
25              
26             class_type Rel, { class => 'WWW::Google::Contacts::Type::Rel' };
27              
28             coerce Rel, from Str, via {
29             require WWW::Google::Contacts::Type::Rel;
30             WWW::Google::Contacts::Type::Rel->new( ( $_ =~ m{^http} )
31             ? ( uri => $_ )
32             : ( name => $_ ),
33             );
34             };
35              
36             subtype XmlBool, as Bool;
37              
38             coerce XmlBool, from Str, via {
39             return 1 if ( $_ =~ m{^true$}i );
40             return 0;
41             };
42              
43             class_type When, { class => 'WWW::Google::Contacts::Type::When' };
44              
45             coerce When, from Str, via {
46             require WWW::Google::Contacts::Type::When;
47             WWW::Google::Contacts::Type::When->new( start_time => $_ );
48             }, from HashRef, via {
49             return undef unless defined $_->{startTime};
50             require WWW::Google::Contacts::Type::When;
51             WWW::Google::Contacts::Type::When->new(
52             start_time => $_->{startTime},
53             defined $_->{endTime} ? ( end_time => $_->{endTime} ) : (),
54             );
55             };
56              
57             class_type Where, { class => 'WWW::Google::Contacts::Type::Where' };
58              
59             coerce Where, from Str, via {
60             require WWW::Google::Contacts::Type::Where;
61             WWW::Google::Contacts::Type::Where->new( value => $_ );
62             }, from HashRef, via {
63             require WWW::Google::Contacts::Type::Where;
64             WWW::Google::Contacts::Type::Where->new( value => $_->{valueString} );
65             };
66              
67             class_type Country, { class => 'WWW::Google::Contacts::Type::Country' };
68              
69             coerce Country, from Str, via {
70             require WWW::Google::Contacts::Type::Country;
71             WWW::Google::Contacts::Type::Country->new( name => $_ );
72             }, from HashRef, via {
73             require WWW::Google::Contacts::Type::Country;
74             WWW::Google::Contacts::Type::Country->new($_);
75             };
76              
77             subtype YomiStr, as Str;
78              
79             coerce YomiStr, from HashRef, via {
80             $_->{content};
81             };