From: Dave Rolsky Date: Thu, 21 Aug 2008 16:37:35 +0000 (+0000) Subject: Make sure to preserve existing metaclass settings for the old meta X-Git-Tag: 0.06_01~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8d7ba9ea782c19f98cbaa4131d900205910f9433;p=gitmo%2FMooseX-StrictConstructor.git Make sure to preserve existing metaclass settings for the old meta object (which could be set via metaclass.pm, policies, etc). --- diff --git a/lib/MooseX/StrictConstructor.pm b/lib/MooseX/StrictConstructor.pm index a1c4a5d..c5bab4e 100644 --- a/lib/MooseX/StrictConstructor.pm +++ b/lib/MooseX/StrictConstructor.pm @@ -23,7 +23,9 @@ sub init_meta my $caller = $p{for_class}; - my $metameta = $caller->meta()->meta(); + my $old_meta = $caller->meta(); + + my $metameta = $old_meta->meta(); unless ( $metameta->can('does_role') && $metameta->does_role( 'MooseX::StrictConstructor::Role::Metaclass' ) ) { @@ -36,7 +38,13 @@ sub init_meta Class::MOP::remove_metaclass_by_name($caller); - $new_meta->name()->initialize($caller); + $new_meta->name()->initialize( $caller, + map { $_ => $old_meta->$_() } + qw( attribute_metaclass + method_metaclass + instance_metaclass + ) + ); } unless ( $caller->meta()->does_role('MooseX::StrictConstructor::Role::Object') )