Add Catalyst::Component::ContextClosure.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Component / ContextClosure.pm
1 package Catalyst::Component::ContextClosure;
2
3 use Moose::Role;
4 use Scalar::Util 'weaken';
5 use namespace::autoclean;
6
7 sub make_context_closure {
8     my ($self, $closure, $ctx) = @_;
9     my $weak_ctx = $ctx;
10     weaken $ctx;
11     return sub { $closure->($ctx, @_) };
12 }
13
14 1;