File Coverage

blib/lib/App/AutoCRUD/View/Xml.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 36 37 97.3


line stmt bran cond sub pod time code
1             package App::AutoCRUD::View::Xml;
2              
3 1     1   615 use 5.010;
  1         4  
4 1     1   8 use strict;
  1         3  
  1         27  
5 1     1   6 use warnings;
  1         3  
  1         32  
6              
7 1     1   7 use Moose;
  1         2  
  1         9  
8             extends 'App::AutoCRUD::View';
9              
10 1     1   8519 use XML::Simple qw/XMLout/;
  1         9111  
  1         9  
11 1     1   93 use Encode qw/encode_utf8/;
  1         5  
  1         56  
12              
13 1     1   10 use namespace::clean -except => 'meta';
  1         2  
  1         12  
14              
15             has 'xml_options' => ( is => 'bare', isa => 'HashRef',
16             default => sub {{
17             KeepRoot => 1,
18             SuppressEmpty => 1,
19             XMLDecl => "<?xml version='1.0' encoding='UTF-8'?>",
20             }} );
21              
22             sub render {
23 1     1 0 4 my ($self, $data, $context) = @_;
24              
25 1     1   506 no warnings 'uninitialized';
  1         3  
  1         119  
26 1         5 my $xml = XMLout({data => $data}, %{$self->{xml_options}});
  1         8  
27              
28 1         2678 return [200, ['Content-type' => 'text/xml'], [encode_utf8($xml)] ];
29             }
30              
31             1;
32              
33              
34             __END__
35              
36              
37