From: Yuval Kogman Date: Sun, 21 Jun 2009 15:13:01 +0000 (-0400) Subject: Check that the value is an object in duck_type TC X-Git-Tag: 0.82~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=58936059d274f9263dedb70a6a41cb6a4a2f9e64;p=gitmo%2FMoose.git Check that the value is an object in duck_type TC --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index b2da981..a9bb443 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -371,14 +371,17 @@ sub duck_type { 'Object', sub { my $obj = $_; + my $class = blessed($obj) || return; + return if $class eq 'Regexp'; return 0 unless all { $obj->can($_) } @methods; return 1; }, sub { my $obj = $_; + my $class = blessed($obj); my @missing_methods = grep { !$obj->can($_) } @methods; return - "${\blessed($obj)} is missing methods '@missing_methods'"; + "$class is missing methods '@missing_methods'"; }, ) );