File Coverage

blib/lib/App/AutoCRUD/View/Xml.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 32 33 96.9


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