$exporting_package,
$exporter,
\@exports_from,
- $is_reexport
+ $is_reexport,
+ ($args{init_meta_params} || []),
);
$methods{unimport} = $class->_make_unimport_sub(
my $exporter = shift;
my $exports_from = shift;
my $is_reexport = shift;
+ my $init_meta_params = shift;
return sub {
strict->import;
warnings->import;
+ my %extra_args;
+ # don't want to just force @_ into a hash, since it really actually is
+ # an array
+ for my $i (1..$#_) {
+ if (grep { $_ eq $_[$i] } @$init_meta_params) {
+ $extra_args{$_[$i]} = $_[$i + 1];
+ splice @_, $i, 2;
+ }
+ }
+
my $did_init_meta;
for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) {
# Moose::Exporter, which in turn sets $CALLER, so we need
# to protect against that.
local $CALLER = $CALLER;
- $c->init_meta( for_class => $CALLER, metaclass => $metaclass );
+ $c->init_meta(
+ %extra_args,
+ for_class => $CALLER,
+ metaclass => $metaclass,
+ );
$did_init_meta = 1;
}
#!/usr/bin/perl
use strict;
use warnings;
-use Test::More skip_all => "not implemented yet";
-#use Test::More tests => 4;
+use Test::More tests => 4;
my @init_meta_args;
);
}
-is_deeply(\@init_meta_args, [
- {
- for_class => 'My::Moose::User',
- metaclass => 'Moose::Meta::Class'
- }
-], "attribute wasn't passed in yet");
-
ok(My::Moose::User->meta->get_attribute('counter')->has_accessor, 'our exported sugar works');
{
};
}
-is_deeply(\@init_meta_args, [
- {
- for_class => 'My::Other::Moose::User',
- metaclass => 'Moose::Meta::Class'
- attribute => 'counter',
- }
-], "got attribute in our init_meta params");
+ok(My::Moose::User->meta->get_attribute('counter')->has_accessor, 'our extra exporter option worked');
+ok(!exists $init_meta_args[0]->{attribute},
+ "attribute wasn't passed in yet");
+
+is($init_meta_args[1]->{attribute}, 'counter',
+ "got attribute in our init_meta params");
-ok(My::Moose::User->meta->get_attribute('counter')->has_accessor, 'our extra exporter option worked');