From: Stevan Little Date: Wed, 12 Dec 2007 22:17:35 +0000 (+0000) Subject: some tweaks X-Git-Tag: 0_49~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=715adbb7a3c497d566ad75e4796a1b4b963a2ce5;p=gitmo%2FClass-MOP.git some tweaks --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 789ebe4..ad63d44 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -122,11 +122,7 @@ sub construct_class_instance { } # and check the metaclass compatibility - $meta->check_metaclass_compatability(); - - # initialize some stuff - $meta->get_method_map; - $meta->reset_package_cache_flag; + $meta->check_metaclass_compatability(); Class::MOP::store_metaclass_by_name($package_name, $meta); @@ -138,7 +134,8 @@ sub construct_class_instance { $meta; } -sub reset_package_cache_flag { +sub reset_package_cache_flag { (shift)->{'$!_package_cache_flag'} = undef } +sub update_package_cache_flag { # NOTE: # we can manually update the cache number # since we are actually adding the method @@ -501,7 +498,7 @@ sub add_method { my $full_method_name = ($self->name . '::' . $method_name); $self->add_package_symbol("&${method_name}" => subname $full_method_name => $body); - $self->reset_package_cache_flag; + $self->update_package_cache_flag; } { @@ -578,7 +575,7 @@ sub alias_method { || confess "Your code block must be a CODE reference"; $self->add_package_symbol("&${method_name}" => $body); - $self->reset_package_cache_flag; + $self->update_package_cache_flag; } sub has_method { @@ -613,7 +610,7 @@ sub remove_method { $self->remove_package_symbol("&${method_name}"); - $self->reset_package_cache_flag; + $self->update_package_cache_flag; return $removed_method; } @@ -992,13 +989,17 @@ metaclass you are creating is compatible with the metaclasses of all your ancestors. For more inforamtion about metaclass compatibility see the C section in L. -=item B +=item B This will reset the package cache flag for this particular metaclass it is basically the value of the C function. This is very rarely needed from outside of C but in some cases you might want to use it, so it is here. +=item B + +Clear this flag, used in Moose. + =back =head2 Object instance construction and cloning diff --git a/t/010_self_introspection.t b/t/010_self_introspection.t index 14cd9ca..92b7c63 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 201; +use Test::More tests => 203; use Test::Exception; BEGIN { @@ -52,6 +52,7 @@ my @class_mop_class_methods = qw( initialize reinitialize create + update_package_cache_flag reset_package_cache_flag create_anon_class is_anon_class