Serialize/XML/Hash/LX.pm

filter: Statementstmt 85.7% 12 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 89.4% 17 / 19 CC 1 SCAR 0.6
CC
1
Cov
86%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Deserialize/XML/Hash/LX.pm ↑ Summary
1 #
2 # Catlyst::Action::Serialize::XML::Hash::LX.pm
3 # Created by: Mons Anderson, <mons@cpan.org>
4 #
5 # $Id$
6  
7 package Catalyst::Action::Serialize::XML::Hash::LX;
8  
9 =head1 NAME
10  
11 Catalyst::Action::Serialize::XML::Hash::LX - XML::Hash::LX serializer for Catalyst
12  
13 =head1 SYNOPSIS
14  
15 package Foo::Controller::Bar;
16  
17 __PACKAGE__->config(
18 default => 'text/xml',
19 map => {
20 'text/xml' => 'XML::Hash::LX',
21 # or
22 'text/xml' => [ 'XML::Hash::LX', { XML::Hash::LX options } ],
23 },
24 )
25 sub end : ActionClass('Serialize') {}
26  
27 =head1 DESCRIPTION
28  
29 L<XML::Hash::LX> serializer for L<Catalyst::Action::Serialize>
30  
31 =cut
32  
33 1 ▶use 5.006002;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 ▶use base 'Catalyst::Action';
Subroutine BEGIN: called CC=1 SCAR=0.0
38 0 ▶use XML::Hash::LX 'hash2xml';
Subroutine BEGIN: called CC=1 SCAR=2.6
39  
40 our $VERSION = '0.06';
41  
42 sub execute {
43 my $self = shift;
44 my ( $controller, $c, $opts ) = @_;
45
46 my $stash_key = (
47 $controller->{'serialize'} ?
48 $controller->{'serialize'}->{'stash_key'} :
49 $controller->{'stash_key'}
50 ) || 'rest';
51 my $output = eval {
52 hash2xml( $c->stash->{$stash_key}, $opts ? ( ref $opts eq 'ARRAY' ? @$opts : %$opts ) : () );
53 };
54 return $@ if $@;
55 $c->response->output( $output );
56 return 1;
57 }
58  
59 =head1 SEE ALSO
60  
61 =over 4
62  
63 =item * L<Catalyst::Action::Serialize>
64  
65 =item * L<XML::Hash::LX>
66  
67 =back
68  
69 =head1 AUTHOR
70  
71 Mons Anderson, C<< <mons at cpan.org> >>
72  
73 =head1 COPYRIGHT & LICENSE
74  
75 Copyright 2009 Mons Anderson, all rights reserved.
76  
77 This program is free software; you can redistribute it and/or modify it
78 under the same terms as Perl itself.
79  
80 =cut
81  
82 1;
« Deserialize/XML/Hash/LX.pm ↑ Summary