From: Chris Prather Date: Wed, 1 Jul 2009 14:32:47 +0000 (-0400) Subject: apply patch from ash on #moose X-Git-Tag: 0.89~9^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3ea3a0336de0ce0f9f2b237d833124df597c539c;p=gitmo%2FClass-MOP.git apply patch from ash on #moose --- diff --git a/Changes b/Changes index 1252e51..ab8dca5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension Class-MOP. + * Class::MOP::Method + - Fix bug from MooseX::Types passing blessed code references + 0.89 * Class::MOP::Instance - add inline version of rebless_instance_structure. (doy) diff --git a/lib/Class/MOP/Method.pm b/lib/Class/MOP/Method.pm index f2c8972..9907bd7 100644 --- a/lib/Class/MOP/Method.pm +++ b/lib/Class/MOP/Method.pm @@ -5,7 +5,7 @@ use strict; use warnings; use Carp 'confess'; -use Scalar::Util 'weaken'; +use Scalar::Util 'weaken', 'reftype'; our $VERSION = '0.88'; $VERSION = eval $VERSION; @@ -28,7 +28,7 @@ sub wrap { my %params = @args; my $code = $params{body}; - ('CODE' eq ref($code)) + (ref $code && 'CODE' eq reftype($code)) || confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")"; ($params{package_name} && $params{name}) diff --git a/t/030_method.t b/t/030_method.t index 4987909..b968deb 100644 --- a/t/030_method.t +++ b/t/030_method.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 46; +use Test::More tests => 47; use Test::Exception; use Class::MOP; @@ -70,6 +70,10 @@ dies_ok { Class::MOP::Method->wrap(sub { 'FAIL' }, name => '__ANON__') } '... bad args for &wrap'; +lives_ok { + Class::MOP::Method->wrap(bless(sub { 'FAIL' }, "Foo"), name => '__ANON__', package_name => 'Foo::Bar') +} '... blessed coderef to &wrap'; + my $clone = $method->clone( package_name => 'NewPackage', name => 'new_name',