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) = @_;