make delayed setup components work so implements+does with required methods in the...
[catagits/Reaction.git] / lib / Reaction / Class.pm
index 7813f48..64116ce 100644 (file)
@@ -147,15 +147,20 @@ sub setup_and_cleanup {
         shift if $_[0] eq 'as';
         push(@methods, [ $name, shift ]);
       };
+    my $s = $setup;
     foreach my $meth ($self->delayed_methods) {
       $save_delayed{$meth} = $package->can($meth);
-      local *{"${package}::${meth}"} =
-        Sub::Name::subname "${self}::${meth}" => sub {
-          push(@apply_after, [ $meth => @_ ]);
-        };
+      my $s_copy = $s;
+      $s = sub {
+        local *{"${package}::${meth}"} =
+          Sub::Name::subname "${self}::${meth}" => sub {
+            push(@apply_after, [ $meth => @_ ]);
+          };
+        $s_copy->(@_);
+      };
     }
     # XXX - need additional fuckery to handle multi-class-per-file
-    $setup->(); # populate up the crap
+    $s->(); # populate up the crap
   }
   my %exports = $self->exports_for_package($package);
   {