File Coverage

blib/lib/App/AutoCRUD/View/Xml.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             package App::AutoCRUD::View::Xml;
2              
3 1     1   487 use 5.010;
  1         3  
  1         34  
4 1     1   3 use strict;
  1         3  
  1         29  
5 1     1   5 use warnings;
  1         1  
  1         24  
6              
7 1     1   4 use Moose;
  1         2  
  1         8  
8             extends 'App::AutoCRUD::View';
9              
10 1     1   4802 use XML::Simple qw/XMLout/;
  0            
  0            
11             use Encode qw/encode_utf8/;
12              
13             use namespace::clean -except => 'meta';
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             my ($self, $data, $context) = @_;
23              
24             my $xml = XMLout({data => $data}, %{$self->{xml_options}});
25              
26             return [200, ['Content-type' => 'text/xml'], [encode_utf8($xml)] ];
27             }
28              
29             1;
30              
31              
32             __END__
33              
34              
35