VMOMI/PrimitiveType.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 30 SCAR 17.9
CC
2
Cov
0%
val
6.0
new
2.0
serialize
2.0
CRAP 6.0
1 package VMOMI::PrimitiveType;
2  
3 use Encode qw(decode_utf8 encode_utf8);
4  
5 use constant P5NS => 'VMOMI';
6  
7 sub new {
8 my ($class, $val, $type) = @_;
9 my $self = { val => $val, type => $type };
10 return bless $self, $class;
11 }
12  
13 sub serialize {
14 my ($self, $tag) = @_;
15 my ($node, $value, $xsd_type);
16
17 $xsd_type = "xsd:" . $self->{'type'};
18 $node = new XML::LibXML::Element($tag);
19 $node->setAttribute('xsi:type', $xsd_type);
20
21 $value = encode_utf8($self->{'val'});
22 $node->appendText($value);
23
24 return $node;
25 }
26  
27 sub val {
28 my $self = shift;
29 $self->{'val'} = shift if @_;
30 return $self->{'val'};
31 }
32  
33 1;