X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FModule.pm;h=4384fa0e32fe728f3aa5ab84272e485c2af01f61;hb=a39e954129372fa75494ba57ea876c35f91b1457;hp=e88531dbbe2d51ee702771d8438ecfdec8a1af61;hpb=b397e301500c5ffc86bbe79ccf7c31119a267ba0;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index e88531d..4384fa0 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -1,8 +1,6 @@ package Mouse::Meta::Module; use Mouse::Util qw/:meta get_code_package get_code_ref load_class not_supported/; # enables strict and warnings -use Mouse::Util::TypeConstraints (); - use Carp (); use Scalar::Util (); @@ -72,14 +70,12 @@ sub remove_attribute { delete $_[0]->{attributes}->{$_[1]} } # XXX: for backward compatibility my %foreign = map{ $_ => undef } qw( Mouse Mouse::Role Mouse::Util Mouse::Util::TypeConstraints - Carp Scalar::Util + Carp Scalar::Util List::Util ); sub _code_is_mine{ - my($self, $code) = @_; - - my $package = get_code_package($code); +# my($self, $code) = @_; - return !exists $foreign{$package}; + return !exists $foreign{ get_code_package($_[1]) }; } sub add_method; @@ -90,14 +86,13 @@ sub has_method { defined($method_name) or $self->throw_error('You must define a method name'); - return 1 if $self->{methods}{$method_name}; - - my $code = get_code_ref($self->{package}, $method_name); - - return $code && $self->_code_is_mine($code); + return defined($self->{methods}{$method_name}) || do{ + my $code = get_code_ref($self->{package}, $method_name); + $code && $self->_code_is_mine($code); + }; } -sub get_method_body{ +sub get_method_body { my($self, $method_name) = @_; defined($method_name) @@ -105,19 +100,19 @@ sub get_method_body{ return $self->{methods}{$method_name} ||= do{ my $code = get_code_ref($self->{package}, $method_name); - ($code && $self->_code_is_mine($code)) ? $code : undef; + $code && $self->_code_is_mine($code) ? $code : undef; }; } sub get_method{ my($self, $method_name) = @_; - if($self->has_method($method_name)){ + if(my $code = $self->get_method_body($method_name)){ my $method_metaclass = $self->method_metaclass; load_class($method_metaclass); return $method_metaclass->wrap( - body => $self->get_method_body($method_name), + body => $code, name => $method_name, package => $self->name, associated_metaclass => $self, @@ -146,7 +141,7 @@ sub get_method_list { my $superclasses; if(exists $options{superclasses}){ - if(Mouse::Util::TypeConstraints::_is_a_metarole($self)){ + if(Mouse::Util::is_a_metarole($self)){ delete $options{superclasses}; } else{ @@ -293,7 +288,7 @@ Mouse::Meta::Module - The base class for Mouse::Meta::Class and Mouse::Meta::Rol =head1 VERSION -This document describes Mouse version 0.40_01 +This document describes Mouse version 0.40_05 =head1 SEE ALSO