PRANG/Graph/Meta/Attr.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 11 / 11 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
register_implementation
1.0
CRAP 1.0
« PRANG/Cookbook/Node.pm ↑ Summary PRANG/XMLSchema/Whatever.pm »
1  
2 package PRANG::Graph::Meta::Attr;
3  
4 9 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 has 'xmlns' =>
7 is => "rw",
8 isa => "Str",
9 predicate => "has_xmlns",
10 ;
11  
12 9 has 'xml_name' =>
13 is => "rw",
14 isa => "Str",
15 predicate => "has_xml_name",
16 ;
17  
18 9 has 'xml_required' =>
19 is => "rw",
20 isa => "Bool",
21 predicate => "has_xml_required",
22 ;
23  
24 9 has 'xmlns_attr' =>
25 is => "rw",
26 isa => "Str",
27 predicate => "has_xmlns_attr",
28 ;
29  
30 package Moose::Meta::Attribute::Custom::Trait::PRANG::Attr;
31 sub register_implementation {
32 9 ▶ "PRANG::Graph::Meta::Attr";
Subroutine register_implementation: called CC=1 SCAR=0.0
33 };
34  
35 9 1;
36  
37 =head1 NAME
38  
39 PRANG::Graph::Meta::Attr - metaclass metarole for XML attributes
40  
41 =head1 SYNOPSIS
42  
43 package My::XML::Language::Node;
44  
45 use Moose;
46 use PRANG::Graph;
47  
48 has_attr 'someattr' =>
49 is => "rw",
50 isa => $str_subtype,
51 predicate => "has_someattr",
52 ;
53  
54 =head1 DESCRIPTION
55  
56 When defining a class, you mark attributes which correspond to XML
57 attributes. To do this in a way that the PRANG marshalling machinery
58 can use when converting to XML and back, make the attributes have this
59 metaclass.
60  
61 You could do this in principle with:
62  
63 has 'someattr' =>
64 traits => ['PRANG::Attr'],
65 ...
66  
67 But L<PRANG::Graph> exports a convenient shorthand for you to use.
68  
69 If you like, you can also set the C<xmlns> and C<xml_name> attribute
70 property, to override the default behaviour, which is to assume that
71 the XML attribute name matches the Moose attribute name, and that the
72 XML namespace of the attribute is empty. Note if you specify the
73 C<xmlns> for an attribute, it I<must> have that namespace set, or it
74 is not the same attribute.
75  
76 If you set the C<xml_required> property, then it is an error for the
77 property not to be set when parsing or emitting.
78  
79 Setting the C<xmlns> attribute to C<*> will allow any XML namespace to
80 be set for that attribute. In this case, you should also set the
81 C<xmlns_attr> property, which should refer to another attribute which
82 will record which XML namespace URI was passed in. This introduces a
83 potential ambiguity; the same attribute may be passed in multiple
84 times, with different XML namespaces.
85  
86 =head1 SEE ALSO
87  
88 L<PRANG::Graph::Meta::Class>, L<PRANG::Graph::Meta::Element>
89  
90 =head1 AUTHOR AND LICENCE
91  
92 Development commissioned by NZ Registry Services, and carried out by
93 Catalyst IT - L<http://www.catalyst.net.nz/>
94  
95 Copyright 2009, 2010, NZ Registry Services. This module is licensed
96 under the Artistic License v2.0, which permits relicensing under other
97 Free Software licenses.
98  
99 =cut
« PRANG/Cookbook/Node.pm ↑ Summary PRANG/XMLSchema/Whatever.pm »