X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=trunk%2Ft%2Flib%2FTestApp%2FController%2FContextClosure.pm;fp=trunk%2Ft%2Flib%2FTestApp%2FController%2FContextClosure.pm;h=8a5cbc820687c240212fdc3ffe367b1896a68286;hb=e28a6876ad3e11890226e5bab6df4b0725e0981e;hp=0000000000000000000000000000000000000000;hpb=21c94d83082b43028cafcfb18659090b13d832fa;p=catagits%2FCatalyst-Runtime.git diff --git a/trunk/t/lib/TestApp/Controller/ContextClosure.pm b/trunk/t/lib/TestApp/Controller/ContextClosure.pm new file mode 100644 index 0000000..8a5cbc8 --- /dev/null +++ b/trunk/t/lib/TestApp/Controller/ContextClosure.pm @@ -0,0 +1,29 @@ +package TestApp::Controller::ContextClosure; + +use Moose; + +BEGIN { + extends 'Catalyst::Controller'; + with 'Catalyst::Component::ContextClosure'; +} + +sub normal_closure : Local { + my ($self, $ctx) = @_; + $ctx->stash(closure => sub { + $ctx->response->body('from normal closure'); + }); + $ctx->response->body('stashed normal closure'); +} + +sub context_closure : Local { + my ($self, $ctx) = @_; + $ctx->stash(closure => $self->make_context_closure(sub { + my ($ctx) = @_; + $ctx->response->body('from context closure'); + }, $ctx)); + $ctx->response->body('stashed context closure'); +} + +__PACKAGE__->meta->make_immutable; + +1;