X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FModule.pm;h=227313e4bb060b3a85a2a1fb065f153bacd7acae;hp=f0a671175c94d9f6f7bab94024494fc4a511ffb9;hb=034587d897c53d4df84085a9229334bd2d51f1c6;hpb=bc69ee88207ce5c53f5c02dbd44cfabfbe6bae70 diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index f0a6711..227313e 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -87,11 +87,11 @@ sub add_method { $code = \&{$code}; # coerce } - $self->{methods}->{$name}++; # Moose stores meta object here. + $self->{methods}->{$name} = $code; # Moose stores meta object here. my $pkg = $self->name; no strict 'refs'; - no warnings 'redefine'; + no warnings 'redefine', 'once'; *{ $pkg . '::' . $name } = $code; } @@ -114,13 +114,34 @@ sub has_method { defined($method_name) or $self->throw_error('You must define a method name'); - return 1 if $self->{methods}->{$method_name}; + return 1 if $self->{methods}{$method_name}; - my $code = do{ no strict 'refs'; *{$self->{package} . '::' . $method_name}{CODE} }; + my $code = do{ + no strict 'refs'; + no warnings 'once'; + *{ $self->{package} . '::' . $method_name }{CODE}; + }; return $code && $self->_code_is_mine($code); } +sub get_method_body{ + my($self, $method_name) = @_; + + defined($method_name) + or $self->throw_error('You must define a method name'); + + return $self->{methods}{$method_name} ||= do{ + my $code = do{ + no strict 'refs'; + no warnings 'once'; + *{$self->{package} . '::' . $method_name}{CODE}; + }; + + ($code && $self->_code_is_mine($code)) ? $code : undef; + }; +} + sub get_method{ my($self, $method_name) = @_; @@ -303,6 +324,10 @@ __END__ Mouse::Meta::Module - The base class for Mouse::Meta::Class and Mouse::Meta::Role +=head1 VERSION + +This document describes Mouse version 0.40 + =head1 SEE ALSO L