From b083bf7fc20aec70aea958a4edaa904cf600c6ac Mon Sep 17 00:00:00 2001 From: Chad Granum Date: Sat, 5 Jul 2014 13:34:37 -0700 Subject: [PATCH] Fix can() so that it will nto die when called on a package The Catalyst test body_fh.t was exploding because it gets this 'can' method on it's object. The latest Test::Builder alpha also calls ->can(...) on test packages, in this case causing an error since the package is not a hashref, but instead is just a string. This will do the expected behavior for plack, but not explode if someone calls 'can' on the package. --- lib/Plack/Util.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Plack/Util.pm b/lib/Plack/Util.pm index 6a3b5d05f..c9549a435 100644 --- a/lib/Plack/Util.pm +++ b/lib/Plack/Util.pm @@ -309,7 +309,8 @@ package Plack::Util::Prototype; our $AUTOLOAD; sub can { - $_[0]->{$_[1]}; + return $_[0]->{$_[1]} if Scalar::Util::blessed($_[0]); + goto &UNIVERSAL::can; } sub AUTOLOAD {