From: Dave Rolsky Date: Wed, 27 Aug 2008 16:37:08 +0000 (+0000) Subject: Refactored/reformatted _fix_metaclass_incompatibility in order to make X-Git-Tag: 0.55_04~2^2~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a43804a5b10796e7c6f5930682535d1b87fcd6df;p=gitmo%2FMoose.git Refactored/reformatted _fix_metaclass_incompatibility in order to make it a little simpler to read, and remove a level of indentation. --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index f733a9e..cecf9fb 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -302,43 +302,44 @@ sub _fix_metaclass_incompatability { # get the name, make sure we take # immutable classes into account - my $super_meta_name = ($meta->is_immutable + my $super_meta_name + = $meta->is_immutable ? $meta->get_mutable_metaclass_name - : ref($meta)); + : ref($meta); - # but if we have anything else, - # we need to check it out ... - unless (# see if of our metaclass is incompatible + next if + # if our metaclass is compatible $self->isa($super_meta_name) and - # and see if our instance metaclass is incompatible - $self->instance_metaclass->isa($meta->instance_metaclass) - ) { - if ( $meta->isa(ref($self)) ) { - unless ( $self->is_pristine ) { - confess "Not reinitializing metaclass for " . $self->name . ", it isn't pristine"; - } - # also check values %{ $self->get_method_map } for any generated methods - - # NOTE: - # We might want to consider actually - # transfering any attributes from the - # original meta into this one, but in - # general you should not have any there - # at this point anyway, so it's very - # much an obscure edge case anyway - $self = $meta->reinitialize( - $self->name, - attribute_metaclass => $meta->attribute_metaclass, - method_metaclass => $meta->method_metaclass, - instance_metaclass => $meta->instance_metaclass, - ); - } else { - # this will be called soon enough, for now we let it slide - # $self->check_metaclass_compatability() + # and our instance metaclass is also compatible then no + # fixes are needed + $self->instance_metaclass->isa( $meta->instance_metaclass ); + + if ( $meta->isa( ref($self) ) ) { + unless ( $self->is_pristine ) { + confess "Not reinitializing metaclass for " + . $self->name + . ", it isn't pristine"; } + + # also check values %{ $self->get_method_map } for any generated methods + + # NOTE: + # We might want to consider actually + # transfering any attributes from the + # original meta into this one, but in + # general you should not have any there + # at this point anyway, so it's very + # much an obscure edge case anyway + $self = $meta->reinitialize( + $self->name, + attribute_metaclass => $meta->attribute_metaclass, + method_metaclass => $meta->method_metaclass, + instance_metaclass => $meta->instance_metaclass, + ); } } + return $self; }