From: Yuval Kogman Date: Sun, 27 Jan 2008 15:37:18 +0000 (+0000) Subject: more correct X-Git-Tag: 0_53~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e253285df25388fd59daa4b8c059e18be5480330;p=gitmo%2FClass-MOP.git more correct --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 40c1c19..da44190 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -416,12 +416,21 @@ sub rebless_instance { # rebless! $meta_instance->rebless_instance_structure($instance, $self); - # check and upgrade all attributes + my %params; + foreach my $attr ( $self->compute_all_applicable_attributes ) { if ( $attr->has_value($instance) ) { - $attr->set_value($instance, $attr->get_value($instance) ); + if ( defined( my $init_arg = $attr->init_arg ) ) { + $params{$init_arg} = $attr->get_value($instance); + } else { + $attr->set_value($instance); + } } } + + foreach my $attr ($self->compute_all_applicable_attributes) { + $attr->initialize_instance_slot($meta_instance, $instance, \%params); + } } # Inheritance