From: Jesse Luehrs Date: Mon, 27 Sep 2010 07:02:53 +0000 (-0500) Subject: handle role reinitialization too X-Git-Tag: 1.15~40 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6feff4da00150d5d62ef567ce007936bb76eac6c;p=gitmo%2FMoose.git handle role reinitialization too --- diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index 11e1b59..f524283 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -188,11 +188,25 @@ sub reinitialize { ); } - return $self->SUPER::reinitialize( + # don't need to remove generated metaobjects here yet, since we don't + # yet generate anything in roles. this may change in the future though... + # keep an eye on that + my $new_meta = $self->SUPER::reinitialize( $pkg, %existing_classes, @_, ); + $new_meta->_restore_metaobjects_from($meta) + if $meta && $meta->isa('Moose::Meta::Role'); + return $new_meta; +} + +sub _restore_metaobjects_from { + my $self = shift; + my ($old_meta) = @_; + + $self->_restore_metamethods_from($old_meta); + $self->_restore_metaattributes_from($old_meta); } sub add_attribute {