From: Dave Rolsky Date: Thu, 21 Apr 2011 20:33:28 +0000 (-0500) Subject: Don't assume that value that fails a duck type constraint is blessed or we get undef... X-Git-Tag: 2.0100~49 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9f45e2edbf684833f963bf2c50f1a6ca7ca7a99;p=gitmo%2FMoose.git Don't assume that value that fails a duck type constraint is blessed or we get undef warnings --- diff --git a/lib/Moose/Meta/TypeConstraint/DuckType.pm b/lib/Moose/Meta/TypeConstraint/DuckType.pm index fa70470..3b1a1c0 100644 --- a/lib/Moose/Meta/TypeConstraint/DuckType.pm +++ b/lib/Moose/Meta/TypeConstraint/DuckType.pm @@ -99,6 +99,8 @@ sub get_message { my @methods = grep { !$value->can($_) } @{ $self->methods }; my $class = blessed $value; + $class ||= $value; + return $class . " is missing methods " . english_list(map { "'$_'" } @methods);