From: gfx Date: Sun, 4 Oct 2009 07:21:19 +0000 (+0900) Subject: add_method() accepts method objects X-Git-Tag: 0.37_02~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=78dc5ed14c0d04c8b73dc8ec701704d72b68e32c;p=gitmo%2FMouse.git add_method() accepts method objects --- diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 1c18447..9fefa10 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -88,7 +88,7 @@ sub add_method { } if(ref($code) ne 'CODE'){ - not_supported 'add_method for a method object'; + $code = \&{$code}; # coerce } $self->{methods}->{$name}++; # Moose stores meta object here. @@ -115,6 +115,9 @@ sub _code_is_mine{ sub has_method { my($self, $method_name) = @_; + defined($method_name) + or $self->throw_error('You must define a method name'); + return 1 if $self->{methods}->{$method_name}; my $code = do{ no strict 'refs'; *{$self->{package} . '::' . $method_name}{CODE} };