Add test for ContextClosure.
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / ContextClosure.pm
1 package TestApp::Controller::ContextClosure;
2
3 use Moose;
4
5 BEGIN {
6     extends 'Catalyst::Controller';
7     with 'Catalyst::Component::ContextClosure';
8 }
9
10 sub normal_closure : Local {
11     my ($self, $ctx) = @_;
12     $ctx->stash(closure => sub {
13         $ctx->response->body('from normal closure');
14     });
15     $ctx->response->body('stashed normal closure');
16 }
17
18 sub context_closure : Local {
19     my ($self, $ctx) = @_;
20     $ctx->stash(closure => $self->make_context_closure(sub {
21         $ctx->response->body('from context closure');
22     }, $ctx));
23     $ctx->response->body('stashed context closure');
24 }
25
26 __PACKAGE__->meta->make_immutable;
27
28 1;