From: gfx Date: Sun, 27 Sep 2009 08:58:31 +0000 (+0900) Subject: Fix compatibility issue on Ark X-Git-Tag: 0.37~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c6d8f5caf4ee3eccf6d417ddb19d51ebdc209112;p=gitmo%2FMouse.git Fix compatibility issue on Ark --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index d3eaa3c..fc1cb8f 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -31,8 +31,12 @@ sub _process_options{ my $can_be_required = defined( $args->{init_arg} ); if(exists $args->{builder}){ + # XXX: + # Moose refuses a CODE ref builder, but Mouse doesn't for backward compatibility + # This feature will be changed in a future. (gfx) $class->throw_error('builder must be a defined scalar value which is a method name') - if ref $args->{builder} || !(defined $args->{builder}); + #if ref $args->{builder} || !defined $args->{builder}; + if !defined $args->{builder}; $can_be_required++; } diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm index 1fb7758..87aaa8e 100644 --- a/lib/Mouse/Meta/Role.pm +++ b/lib/Mouse/Meta/Role.pm @@ -2,12 +2,23 @@ package Mouse::Meta::Role; use strict; use warnings; -use Mouse::Util qw(:meta not_supported english_list); +use Mouse::Util qw(:meta not_supported english_list get_code_info); use Mouse::Meta::Module; our @ISA = qw(Mouse::Meta::Module); sub method_metaclass(){ 'Mouse::Meta::Role::Method' } # required for get_method() +# XXX: for backward compatibility +my %foreign = map{ $_ => undef } qw(Mouse::Role Carp Scalar::Util UNIVERSAL); +sub _code_is_mine{ + my($self, $code) = @_; + + my($package, $name) = get_code_info($code); + + return $package && !exists $foreign{$package}; +} + + sub _construct_meta { my $class = shift;