X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP.pm;h=5ed90a12e41a4b43ec8db2954fee07a8dcaddbc5;hb=92330ee202d6c3d1291e562bb392a1903a062a7e;hp=ef130fc5083cfd9a712b3ed59ae3799219dcc714;hpb=c4260b45e76ce008e4c51987b243f2b0ae4313bb;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index ef130fc..5ed90a1 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -179,27 +179,23 @@ Class::MOP::Class->meta->add_attribute( Class::MOP::Class->meta->add_attribute( Class::MOP::Attribute->new('%:methods' => ( reader => { - # NOTE: - # as with the $VERSION and $AUTHORITY above - # sometimes we don't/can't store directly - # inside the instance, so we need the accessor - # to just DWIM 'get_method_map' => sub { my $self = shift; - # FIXME: - # there is a faster/better way - # to do this, I am sure :) - return +{ - map { - $_ => $self->get_method($_) - } grep { - $self->has_method($_) - } $self->list_all_package_symbols - }; + my $map = $self->{'%:methods'}; + + foreach my $symbol ($self->list_all_package_symbols('CODE')) { + my $code = $self->get_package_symbol('&' . $symbol); + + next if exists $map->{$symbol} && + $map->{$symbol}->body == $code; + + $map->{$symbol} = $self->method_metaclass->wrap($code); + } + + return $map; } }, - init_arg => '!............( DO NOT DO THIS )............!', - default => sub { \undef } + default => sub { {} } )) );