X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FTestApp%2FView%2FDump.pm;h=6c4c1ec77b9f4c46a655eacc4d1ed17855ff1e23;hb=9310b818c83f77236e011b34da5506a8dbe0d119;hp=c4c29dbfa4d7ab62618df2389d4eb52214ecae9c;hpb=d5df925fddfbcde957e258928c1abfdffba452bb;p=catagits%2FCatalyst-Runtime.git diff --git a/t/lib/TestApp/View/Dump.pm b/t/lib/TestApp/View/Dump.pm index c4c29db..6c4c1ec 100644 --- a/t/lib/TestApp/View/Dump.pm +++ b/t/lib/TestApp/View/Dump.pm @@ -7,13 +7,15 @@ use Data::Dumper (); use Scalar::Util qw(blessed weaken); sub dump { - my ( $self, $reference ) = @_; + my ( $self, $reference, $purity ) = @_; return unless $reference; + $purity = $purity // 1; + my $dumper = Data::Dumper->new( [$reference] ); $dumper->Indent(1); - $dumper->Purity(1); + $dumper->Purity($purity); $dumper->Useqq(0); $dumper->Deepcopy(1); $dumper->Quotekeys(0); @@ -23,7 +25,7 @@ sub dump { } sub process { - my ( $self, $c, $reference ) = @_; + my ( $self, $c, $reference, $purity ) = @_; # Force processing of on-demand data $c->prepare_body; @@ -37,19 +39,23 @@ sub process { my $context = delete $reference->{_context}; if ( my $output = - $self->dump( $reference ) ) + $self->dump( $reference, $purity ) ) { $c->res->headers->content_type('text/plain'); $c->res->output($output); - # Repair context - $reference->{_context} = $context; - weaken( $reference->{_context} ); - - # Repair body - delete $reference->{__body_type}; - $reference->{_body} = $body; + if ($context) { + # Repair context + $reference->{_context} = $context; + weaken( $reference->{_context} ); + } + + if ($body) { + # Repair body + delete $reference->{__body_type}; + $reference->{_body} = $body; + } return 1; }