line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Action::Serialize::View; |
2
|
|
|
|
|
|
|
$Catalyst::Action::Serialize::View::VERSION = '1.20'; |
3
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
4
|
1
|
|
|
1
|
|
6776
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'Catalyst::Action'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub execute { |
9
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
10
|
2
|
|
|
|
|
6
|
my ( $controller, $c, $view ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Views don't care / are not going to render an entity for 3XX |
13
|
|
|
|
|
|
|
# responses. |
14
|
2
|
50
|
|
|
|
54
|
return 1 if $c->response->status =~ /^(?:204|3\d\d)$/; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $stash_key = ( |
17
|
|
|
|
|
|
|
$controller->{'serialize'} ? |
18
|
|
|
|
|
|
|
$controller->{'serialize'}->{'stash_key'} : |
19
|
2
|
|
50
|
|
|
254
|
$controller->{'stash_key'} |
20
|
|
|
|
|
|
|
) || 'rest'; |
21
|
|
|
|
|
|
|
|
22
|
2
|
50
|
|
|
|
16
|
if ( !$c->view($view) ) { |
23
|
0
|
|
|
|
|
0
|
$c->log->error("Could not load $view, refusing to serialize"); |
24
|
0
|
|
|
|
|
0
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
2
|
100
|
|
|
|
269
|
if ($c->view($view)->process($c, $stash_key)) { |
28
|
1
|
|
|
|
|
130
|
return 1; |
29
|
|
|
|
|
|
|
} else { |
30
|
|
|
|
|
|
|
# This is stupid. Please improve it. |
31
|
1
|
|
33
|
|
|
100
|
my $error = join("\n", @{ $c->error }) || "Error in $view"; |
32
|
1
|
|
|
|
|
11
|
$error .= "\n"; |
33
|
1
|
|
|
|
|
10
|
$c->clear_errors; |
34
|
1
|
|
|
|
|
14
|
die $error; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |