make weaken work on any ref, not just blessed refs
[p5sagit/curry.git] / lib / curry.pm
index 2ad9c1c..9fd6559 100644 (file)
@@ -24,21 +24,21 @@ use Scalar::Util ();
 
 $curry::weak = sub {
   my ($invocant, $code) = splice @_, 0, 2;
-  Scalar::Util::weaken($invocant) if Scalar::Util::blessed($invocant);
+  Scalar::Util::weaken($invocant) if length ref $invocant;
   my @args = @_;
   sub {
-    return unless $invocant;
+    return unless defined $invocant;
     $invocant->$code(@args => @_)
   }
 };
 
 sub AUTOLOAD {
   my $invocant = shift;
-  Scalar::Util::weaken($invocant) if Scalar::Util::blessed($invocant);
+  Scalar::Util::weaken($invocant) if length ref $invocant;
   my ($method) = our $AUTOLOAD =~ /^curry::weak::(.+)$/;
   my @args = @_;
   return sub {
-    return unless $invocant;
+    return unless defined $invocant;
     $invocant->$method(@args => @_);
   }
 }