Add a comment
[gitmo/Mouse.git] / lib / Mouse / Meta / Module.pm
index a4ddb38..5588f29 100755 (executable)
@@ -114,13 +114,29 @@ 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';
+        *{ $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'; *{$self->{package} . '::' . $method_name}{CODE} };
+
+        ($code && $self->_code_is_mine($code)) ? $code : undef;
+    };
+}
+
 sub get_method{
     my($self, $method_name) = @_;