Skip to content

Commit

Permalink
Stash \undef to skip serialisation of body
Browse files Browse the repository at this point in the history
The JSON serialiser (probably quite common) barfs if you try to serialise undef. This is probably good behaviour, because it means you've forgotten to stash the object you want serialising.

To explicitly skip serialisation, therefore, this patch allows you to pass a ref to undef.
  • Loading branch information
Altreus committed Nov 17, 2015
1 parent 1867cfa commit 7c34a43
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/Catalyst/Action/Serialize.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sub execute {
$controller->{'stash_key'}
) || 'rest';
return 1 if $c->response->status =~ /^(?:3\d\d)$/ && ! defined $c->stash->{$stash_key};
return 1 if ref $c->stash->{$stash_key} eq 'SCALAR' and not defined ${ $c->stash->{$stash_key} };

my ( $sclass, $sarg, $content_type ) =
$self->_load_content_plugins( "Catalyst::Action::Serialize",
Expand Down

0 comments on commit 7c34a43

Please sign in to comment.