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