switch to hashref-based _eval_closure
[gitmo/Class-MOP.git] / lib / Class / MOP / Method / Generated.pm
index 2f2b1b8..428d808 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 
 use Carp 'confess';
 
-our $VERSION   = '0.69_01';
+our $VERSION   = '0.71_01';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -44,7 +44,19 @@ sub initialize_body {
     confess "No body to initialize, " . __PACKAGE__ . " is an abstract base class";
 }
 
-
+sub _eval_closure {
+    # my ($self, $captures, $sub_body) = @_;
+    my $__captures = $_[1];
+    eval join(
+        "\n",
+        (map {
+            /^([\@\%\$])/
+                or die "capture key should start with \@, \% or \$: $_";
+            q!my !.$_.q! = !.$1.q!{$__captures->{'!.$_.q!'}};!;
+        } keys %$__captures),
+        $_[2]
+    );
+}
 
 1;