Bump versions for release
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / View.pm
CommitLineData
9a76221e 1package Catalyst::Action::Serialize::View;
930013e6 2use Moose;
3use namespace::autoclean;
9a76221e 4
930013e6 5extends 'Catalyst::Action';
9a76221e 6
3bb36dca 7our $VERSION = '0.82';
6edee33e 8$VERSION = eval $VERSION;
9
9a76221e 10sub execute {
11 my $self = shift;
12 my ( $controller, $c, $view ) = @_;
faf5c20b 13
14 my $stash_key = (
07682cbc 15 $controller->{'serialize'} ?
16 $controller->{'serialize'}->{'stash_key'} :
17 $controller->{'stash_key'}
faf5c20b 18 ) || 'rest';
9a76221e 19
20 if ( !$c->view($view) ) {
21 $c->log->error("Could not load $view, refusing to serialize");
58c1c5f5 22 return;
9a76221e 23 }
24
6d4a379f 25 if ($c->view($view)->process($c, $stash_key)) {
26 return 1;
27 } else {
28 # This is stupid. Please improve it.
29 my $error = join("\n", @{ $c->error }) || "Error in $view";
30 $error .= "\n";
31 $c->clear_errors;
32 die $error;
33 }
9a76221e 34}
35
361;