Updating branch to current revision
[catagits/Catalyst-Runtime.git] / trunk / t / lib / TestApp / Controller / ContextClosure.pm
diff --git a/trunk/t/lib/TestApp/Controller/ContextClosure.pm b/trunk/t/lib/TestApp/Controller/ContextClosure.pm
new file mode 100644 (file)
index 0000000..8a5cbc8
--- /dev/null
@@ -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;