File: | lib/WWW/Google/Contacts/Meta/Attribute/Trait/XmlField.pm |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package WWW::Google::Contacts::Meta::Attribute::Trait::XmlField; | ||||||
2 | |||||||
3 | 12 12 12 | 158 49 1580 | use Moose::Role; | ||||
4 | 12 12 12 | 151 38 104 | use WWW::Google::Contacts::InternalTypes qw( Method ); | ||||
5 | 12 12 12 | 127 38 93 | use MooseX::Types::Moose qw( Str CodeRef Bool ); | ||||
6 | |||||||
7 | has xml_key => ( | ||||||
8 | isa => Str, | ||||||
9 | is => 'ro', | ||||||
10 | required => 1, | ||||||
11 | ); | ||||||
12 | |||||||
13 | # Allow attributes to have custom code for transforming to xml | ||||||
14 | has to_xml => ( | ||||||
15 | isa => CodeRef, | ||||||
16 | is => 'ro', | ||||||
17 | predicate => 'has_to_xml', | ||||||
18 | ); | ||||||
19 | |||||||
20 | has is_element => ( | ||||||
21 | isa => Bool, | ||||||
22 | is => 'ro', | ||||||
23 | default => sub { 0 }, | ||||||
24 | ); | ||||||
25 | |||||||
26 | has include_in_xml => ( | ||||||
27 | isa => Method, | ||||||
28 | is => 'ro', | ||||||
29 | default => sub { sub { 1 } }, | ||||||
30 | coerce => 1, | ||||||
31 | ); | ||||||
32 | |||||||
33 | 12 12 12 | 129 43 88 | no Moose::Role; | ||||
34 | |||||||
35 | package Moose::Meta::Attribute::Custom::Trait::XmlField; | ||||||
36 | 12 | 165 | sub register_implementation {'WWW::Google::Contacts::Meta::Attribute::Trait::XmlField'} | ||||
37 | |||||||
38 | 1; |