X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-Serialize-Data-Serializer.git;a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FDeserialize%2FXML%2FSimple.pm;fp=lib%2FCatalyst%2FAction%2FDeserialize%2FXML%2FSimple.pm;h=0000000000000000000000000000000000000000;hp=c48beadee87eff4d37f8b6bb02645dcf249ac8c4;hb=79025f72c27ba313b3c701cee238f84166f32f9e;hpb=f10c7e1c7eb3b4cb10401dbb86ca8db3dc38ced2 diff --git a/lib/Catalyst/Action/Deserialize/XML/Simple.pm b/lib/Catalyst/Action/Deserialize/XML/Simple.pm deleted file mode 100644 index c48bead..0000000 --- a/lib/Catalyst/Action/Deserialize/XML/Simple.pm +++ /dev/null @@ -1,53 +0,0 @@ -package Catalyst::Action::Deserialize::XML::Simple; - -use Moose; -use namespace::autoclean; -use Scalar::Util qw(openhandle); - -extends 'Catalyst::Action'; - -our $VERSION = '1.07'; -$VERSION = eval $VERSION; - -sub execute { - my $self = shift; - my ( $controller, $c, $test ) = @_; - - eval { - require XML::Simple; - }; - if ($@) { - $c->log->debug("Could not load XML::Simple, refusing to deserialize: $@") - if $c->debug; - return 0; - } - - my $body = $c->request->body; - if ($body) { - my $xs = XML::Simple->new('ForceArray' => 0,); - my $rdata; - eval { - if(openhandle $body){ # make sure we rewind the file handle - seek($body, 0, 0); # in case something has already read from it - } - $rdata = $xs->XMLin( $body ); - }; - if ($@) { - return $@; - } - if (exists($rdata->{'data'})) { - $c->request->data($rdata->{'data'}); - } else { - $c->request->data($rdata); - } - } else { - $c->log->debug( - 'I would have deserialized, but there was nothing in the body!') - if $c->debug; - } - return 1; -} - -__PACKAGE__->meta->make_immutable; - -1;