sub get_method_map {
my $self = shift;
- if (defined $self->{'_package_cache_flag'} &&
- $self->{'_package_cache_flag'} == Class::MOP::check_package_cache_flag($self->name)) {
+ my $current = Class::MOP::check_package_cache_flag($self->name);
+
+ if (defined $self->{'_package_cache_flag'} && $self->{'_package_cache_flag'} == $current) {
return $self->{'methods'};
}
-
+
+ $self->{_package_cache_flag} = $current;
+
my $map = $self->{'methods'};
my $class_name = $self->name;
{ sigil => '&', type => 'CODE', name => $method_name },
Class::MOP::subname($full_method_name => $body)
);
- $self->update_package_cache_flag;
+
+ $self->update_package_cache_flag; # still valid, since we just added the method to the map, and if it was invalid before that then get_method_map updated it
}
{
$self->add_package_symbol(
{ sigil => '&', type => 'CODE', name => $method_name } => $body
);
- $self->update_package_cache_flag;
}
sub has_method {
$self->remove_package_symbol(
{ sigil => '&', type => 'CODE', name => $method_name }
);
-
- $self->update_package_cache_flag;
+
+ $self->update_package_cache_flag; # still valid, since we just removed the method from the map
return $removed_method;
}