From: Dave Rolsky Date: Thu, 7 Aug 2008 16:10:21 +0000 (+0000) Subject: Moose::Exporter now ensures that _every_ init_meta() method is called, X-Git-Tag: 0_55_01~43^2~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42c391b1132b9999f555a7a2e42e1de63085fe6c;p=gitmo%2FMoose.git Moose::Exporter now ensures that _every_ init_meta() method is called, both for the "original" class and anything it re-exports. This means you can re-export Moose.pm without implementing an init_meta. --- diff --git a/lib/Moose/Exporter.pm b/lib/Moose/Exporter.pm index ac98376..d33a8bc 100644 --- a/lib/Moose/Exporter.pm +++ b/lib/Moose/Exporter.pm @@ -31,7 +31,7 @@ sub build_import_methods { } ); - my $import = $class->_make_import_sub($exporter); + my $import = $class->_make_import_sub( $exporter, \@exports_from ); my $unimport = $class->_make_unimport_sub( [ keys %{$exports} ] ); @@ -152,8 +152,9 @@ sub _process_exports { } sub _make_import_sub { - my $class = shift; - my $exporter = shift; + shift; + my $exporter = shift; + my $exports_from = shift; return sub { @@ -179,10 +180,9 @@ sub _process_exports { return; } - if ( $class->can('init_meta') ) { - $class->init_meta( - for_class => $CALLER, - ); + for my $c (grep { $_->can('init_meta') } $class, @{$exports_from} ) { + + $c->init_meta( for_class => $CALLER ); } goto $exporter; diff --git a/t/050_metaclasses/012_moose_exporter.t b/t/050_metaclasses/012_moose_exporter.t index a436ec1..e91249a 100644 --- a/t/050_metaclasses/012_moose_exporter.t +++ b/t/050_metaclasses/012_moose_exporter.t @@ -36,6 +36,11 @@ use Test::Exception; ok( ! WantsMoose->can('has'), 'WantsMoose::has() has been cleaned' ); ok( ! WantsMoose->can('with'), 'WantsMoose::with() has been cleaned' ); can_ok( 'WantsMoose', 'foo' ); + + # This makes sure that Moose->init_meta() happens properly + isa_ok( WantsMoose->meta(), 'Moose::Meta::Class' ); + isa_ok( WantsMoose->new(), 'Moose::Object' ); + } {