X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FExporter.pm;h=023406403312366eec49e566f9306aa7754b2714;hb=a3319906531cef2b41a87138e75461ced7a3394b;hp=40e98b3833e7e108a81be2b514cd7ff1e9bcced3;hpb=df8260e9a27a9d7532a21525223975fcf8e26562;p=gitmo%2FMoose.git diff --git a/lib/Moose/Exporter.pm b/lib/Moose/Exporter.pm index 40e98b3..0234064 100644 --- a/lib/Moose/Exporter.pm +++ b/lib/Moose/Exporter.pm @@ -3,7 +3,7 @@ package Moose::Exporter; use strict; use warnings; -our $VERSION = '0.63'; +our $VERSION = '0.73_01'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -40,7 +40,7 @@ sub build_import_methods { my ( $exports, $is_removable ) = $class->_make_sub_exporter_params( - [ $exporting_package, @exports_from ], $export_recorder ); + [ @exports_from, $exporting_package ], $export_recorder ); my $exporter = Sub::Exporter::build_exporter( { @@ -193,12 +193,18 @@ sub _make_wrapped_sub { } sub _make_wrapper { - shift; + my $class = shift; my $caller = shift; my $sub = shift; my $fq_name = shift; - return sub { $sub->($caller, @_) }; + my $wrapper = sub { $sub->($caller, @_) }; + if (my $proto = prototype $sub) { + # XXX - Perl's prototype sucks. Use & to make set_prototype + # ignore the fact that we're passing a "provate variable" + &Scalar::Util::set_prototype($wrapper, $proto); + } + return $wrapper; } sub _make_import_sub { @@ -262,6 +268,7 @@ sub _make_import_sub { _apply_meta_traits( $CALLER, $traits ); } elsif ( @{$traits} ) { + require Moose; Moose->throw_error( "Cannot provide traits when $class does not have an init_meta() method" ); @@ -291,7 +298,7 @@ sub _apply_meta_traits { return unless @{$traits}; - my $meta = $class->meta(); + my $meta = Class::MOP::class_of($class); my $type = ( split /::/, ref $meta )[-1] or Moose->throw_error( @@ -421,7 +428,9 @@ C module, as long as they all use C. This module provides two public methods: -=head2 Moose::Exporter->setup_import_methods(...) +=over 4 + +=item B<< Moose::Exporter->setup_import_methods(...) >> When you call this method, C build custom C and C methods for your module. The import method will export @@ -433,7 +442,7 @@ exported functions. This method accepts the following parameters: -=over 4 +=over 8 =item * with_caller => [ ... ] @@ -459,18 +468,23 @@ themselves, and therefore wants 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 exported by modules specified by C, so that a module +can selectively override functions exported by another module. C also makes sure all these functions get removed when C is called. =back -=head2 Moose::Exporter->build_import_methods(...) +=item B<< Moose::Exporter->build_import_methods(...) >> Returns two code refs, one for import and one for unimport. Used by C. +=back + =head1 IMPORTING AND init_meta If you want to set an alternative base object class or metaclass @@ -510,7 +524,7 @@ Stevan Little and others. =head1 COPYRIGHT AND LICENSE -Copyright 2008 by Infinity Interactive, Inc. +Copyright 2009 by Infinity Interactive, Inc. L