From: Shawn M Moore Date: Thu, 5 Feb 2009 21:19:39 +0000 (+0000) Subject: Factor out some bits of get_method_list so I can write X-Git-Tag: 0.19~40 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=4724d42ea79c5591e30c1d98f9b434a4185e4da8 Factor out some bits of get_method_list so I can write get_all_method_names --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 93b6f6c..7f2378d 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -69,9 +69,9 @@ sub add_method { } # copied from Class::Inspector -sub get_method_list { +my $get_methods_for_class = sub { my $self = shift; - my $name = $self->name; + my $name = shift; no strict 'refs'; # Get all the CODE symbol table entries @@ -79,8 +79,13 @@ sub get_method_list { grep !/^(?:has|with|around|before|after|blessed|extends|confess|override|super)$/, grep { defined &{"${name}::$_"} } keys %{"${name}::"}; - push @functions, keys %{$self->{'methods'}->{$name}}; + push @functions, keys %{$self->{'methods'}->{$name}} if $self; wantarray ? @functions : \@functions; +}; + +sub get_method_list { + my $self = shift; + $get_methods_for_class->($self, $self->name); } sub add_attribute {