line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Google::Contacts::Roles::HasTypeAndLabel; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$WWW::Google::Contacts::Roles::HasTypeAndLabel::VERSION = '0.39'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
32249
|
use MooseX::Role::Parameterized; |
|
20
|
|
|
|
|
1222290
|
|
|
20
|
|
|
|
|
109
|
|
7
|
20
|
|
|
20
|
|
744197
|
use MooseX::Types::Moose qw( ArrayRef Str ); |
|
20
|
|
|
|
|
133
|
|
|
20
|
|
|
|
|
245
|
|
8
|
20
|
|
|
20
|
|
111144
|
use WWW::Google::Contacts::InternalTypes qw( Rel ); |
|
20
|
|
|
|
|
67
|
|
|
20
|
|
|
|
|
179
|
|
9
|
20
|
|
|
20
|
|
68645
|
use Perl6::Junction qw( any ); |
|
20
|
|
|
|
|
165818
|
|
|
20
|
|
|
|
|
10846
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
parameter valid_types => ( |
12
|
|
|
|
|
|
|
isa => ArrayRef, |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
parameter default_type => ( |
17
|
|
|
|
|
|
|
isa => Str, |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
role { |
22
|
|
|
|
|
|
|
my $param = shift; |
23
|
|
|
|
|
|
|
my $valid_types = $param->valid_types; |
24
|
|
|
|
|
|
|
my $default_type = $param->default_type; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has type => ( |
27
|
|
|
|
|
|
|
isa => Rel, |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
traits => ['XmlField'], |
30
|
|
|
|
|
|
|
xml_key => 'rel', |
31
|
|
|
|
|
|
|
predicate => 'has_type', |
32
|
|
|
|
|
|
|
trigger => \&_type_set, |
33
|
|
|
|
|
|
|
include_in_xml => sub { return $_[0]->has_valid_type }, |
34
|
|
|
|
|
|
|
default => sub { to_Rel($default_type) }, |
35
|
|
|
|
|
|
|
coerce => 1, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has label => ( |
39
|
|
|
|
|
|
|
isa => Str, |
40
|
|
|
|
|
|
|
is => 'rw', |
41
|
|
|
|
|
|
|
traits => ['XmlField'], |
42
|
|
|
|
|
|
|
xml_key => 'label', |
43
|
|
|
|
|
|
|
trigger => \&_label_set, |
44
|
|
|
|
|
|
|
predicate => 'has_label', |
45
|
|
|
|
|
|
|
include_in_xml => sub { return !$_[0]->has_valid_type }, |
46
|
|
|
|
|
|
|
default => sub { $default_type }, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
method has_valid_type => sub { |
50
|
6
|
|
|
6
|
|
7
|
my $self = shift; |
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
51
|
6
|
100
|
|
|
|
10
|
return any( @{$valid_types} ) eq $self->type->name ? 1 : 0; |
|
6
|
|
|
|
|
30
|
|
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
method default_type => sub { |
55
|
0
|
|
|
0
|
|
0
|
return $default_type; |
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# To make sure type and label are always up to date with eachother |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _type_set { |
62
|
4
|
|
|
4
|
|
9
|
my ( $self, $type ) = @_; |
63
|
4
|
50
|
|
|
|
177
|
if ( $type->name eq '' ) { |
64
|
0
|
|
|
|
|
0
|
return $self->type( to_Rel( $self->default_type ) ); |
65
|
|
|
|
|
|
|
} |
66
|
4
|
100
|
66
|
|
|
212
|
return if ( defined $self->label and $self->label eq $type->name ); |
67
|
1
|
|
|
|
|
40
|
$self->label( $type->name ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _label_set { |
71
|
3
|
|
|
3
|
|
5
|
my ( $self, $label ) = @_; |
72
|
3
|
50
|
|
|
|
10
|
if ( $label eq '' ) { |
73
|
0
|
|
|
|
|
0
|
return $self->label( $self->default_type ); |
74
|
|
|
|
|
|
|
} |
75
|
3
|
100
|
66
|
|
|
155
|
return if ( defined $self->type and $self->type->name eq $label ); |
76
|
2
|
|
|
|
|
83
|
$self->type($label); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
20
|
|
|
20
|
|
158
|
no Moose::Role; |
|
20
|
|
|
|
|
41
|
|
|
20
|
|
|
|
|
229
|
|