From: Dave Rolsky Date: Mon, 7 Sep 2009 16:30:25 +0000 (-0500) Subject: Use with_meta in favor of with_caller, which is deprecated X-Git-Tag: 0.89_02~32^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5ac14e89c76186c75f3ff8da493f704ea8a090b3;p=gitmo%2FMoose.git Use with_meta in favor of with_caller, which is deprecated --- diff --git a/lib/Moose/Exporter.pm b/lib/Moose/Exporter.pm index faebc2c..1cff223 100644 --- a/lib/Moose/Exporter.pm +++ b/lib/Moose/Exporter.pm @@ -129,14 +129,16 @@ sub _make_sub_exporter_params { # one group for each 'also' package $groups{$package} = [ - @{ $args->{with_caller} || [] }, @{ $args->{with_meta} || [] }, + @{ $args->{with_caller} || [] }, @{ $args->{as_is} || [] }, - map ":$_", - keys %{ $args->{groups} || {} } + ( + map {":$_"} + keys %{ $args->{groups} || {} } + ) ]; - for my $name ( @{ $args->{with_caller} } ) { + for my $name ( @{ $args->{with_meta} } ) { my $sub = do { no strict 'refs'; \&{ $package . '::' . $name }; @@ -144,7 +146,7 @@ sub _make_sub_exporter_params { my $fq_name = $package . '::' . $name; - $exports{$name} = $class->_make_wrapped_sub( + $exports{$name} = $class->_make_wrapped_sub_with_meta( $fq_name, $sub, $export_recorder, @@ -153,7 +155,7 @@ sub _make_sub_exporter_params { $is_removable{$name} = 1; } - for my $name ( @{ $args->{with_meta} } ) { + for my $name ( @{ $args->{with_caller} } ) { my $sub = do { no strict 'refs'; \&{ $package . '::' . $name }; @@ -161,7 +163,7 @@ sub _make_sub_exporter_params { my $fq_name = $package . '::' . $name; - $exports{$name} = $class->_make_wrapped_sub_with_meta( + $exports{$name} = $class->_make_wrapped_sub( $fq_name, $sub, $export_recorder, @@ -615,14 +617,15 @@ Moose::Exporter - make an import() and unimport() just like Moose.pm use Moose::Exporter; Moose::Exporter->setup_import_methods( - with_caller => [ 'has_rw', 'sugar2' ], - as_is => [ 'sugar3', \&Some::Random::thing ], - also => 'Moose', + with_meta => [ 'has_rw', 'sugar2' ], + as_is => [ 'sugar3', \&Some::Random::thing ], + also => 'Moose', ); sub has_rw { - my ($caller, $name, %options) = @_; - Class::MOP::class_of($caller)->add_attribute($name, + my ( $meta, $name, %options ) = @_; + $meta->add_attribute( + $name, is => 'rw', %options, ); @@ -685,12 +688,13 @@ This method accepts the following parameters: =over 8 -=item * with_caller => [ ... ] +=item * with_meta => [ ... ] This list of function I will be wrapped and then exported. The -wrapper will pass the name of the calling package as the first argument to the -function. Many sugar functions need to know their caller so they can get the -calling package's metaclass object. +wrapper will pass the metaclass object for the caller as its first argument. + +Many sugar functions will need to use this metaclass object to do something to +the calling package. =item * as_is => [ ... ] @@ -708,7 +712,7 @@ to keep it. This is a list of modules which contain functions that the caller wants to export. These modules must also use C. The most common use case will be to export the functions from C. -Functions specified by C or C take precedence over +Functions specified by C or C take precedence over functions exported by modules specified by C, so that a module can selectively override functions exported by another module.