From: Graham Knop Date: Fri, 20 Apr 2018 09:10:44 +0000 (+0200) Subject: make weaken work on any ref, not just blessed refs X-Git-Tag: v2.000000~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2Fcurry.git;a=commitdiff_plain;h=0f8925b5cf64ff572abdf929e9560cda65608aa1 make weaken work on any ref, not just blessed refs --- diff --git a/lib/curry.pm b/lib/curry.pm index 1a9c237..9fd6559 100644 --- a/lib/curry.pm +++ b/lib/curry.pm @@ -24,7 +24,7 @@ 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 defined $invocant; @@ -34,7 +34,7 @@ $curry::weak = sub { 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 {