X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FSerialize.pm;h=fd368788c73bcc1568ec5d273936b5688127c33c;hb=19cd07ecf000cd9fe5652c1a171e1a942902d20c;hp=1eaa1316dfd6c71d32db0a87df724470d5f739aa;hpb=0a6732c935e687213c53f013d925f35083f8c592;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Serialize.pm b/lib/Catalyst/Action/Serialize.pm index 1eaa131..fd36878 100644 --- a/lib/Catalyst/Action/Serialize.pm +++ b/lib/Catalyst/Action/Serialize.pm @@ -7,9 +7,6 @@ extends 'Catalyst::Action::SerializeBase'; use Module::Pluggable::Object; use MRO::Compat; -our $VERSION = '1.05'; -$VERSION = eval $VERSION; - has _encoders => ( is => 'ro', isa => 'HashRef', @@ -26,6 +23,17 @@ sub execute { return 1 if $c->response->has_body; return 1 if scalar @{ $c->error }; return 1 if $c->response->status =~ /^(?:204)$/; + return 1 if defined $c->stash->{current_view}; + return 1 if defined $c->stash->{current_view_instance}; + + # on 3xx responses, serialize if there's something to + # serialize, no-op if not + my $stash_key = ( + $controller->{'serialize'} ? + $controller->{'serialize'}->{'stash_key'} : + $controller->{'stash_key'} + ) || 'rest'; + return 1 if $c->response->status =~ /^(?:3\d\d)$/ && ! defined $c->stash->{$stash_key}; my ( $sclass, $sarg, $content_type ) = $self->_load_content_plugins( "Catalyst::Action::Serialize",