[SCM] libpackage-variant-perl Debian packaging branch, master, updated. debian/1.001003-1-16-g363631d
Robert Sedlacek
rs at 474.at
Thu May 9 17:13:55 UTC 2013
The following commit has been merged in the master branch:
commit 0a7db8d2582be4949a5c321ac449ff6c2e1c1e03
Author: Robert Sedlacek <rs at 474.at>
Date: Mon Nov 28 22:23:42 2011 +0100
allow optional renaming of exported generator
diff --git a/lib/Package/Variant.pm b/lib/Package/Variant.pm
index 7e0cbe0..b0c2698 100644
--- a/lib/Package/Variant.pm
+++ b/lib/Package/Variant.pm
@@ -21,8 +21,10 @@ sub import {
};
*{"${target}::import"} = sub {
my $target = caller;
+ my (undef, %arg) = @_;
+ my $as = defined($arg{as}) ? $arg{as} : $last;
no strict 'refs';
- *{"${target}::${last}"} = sub {
+ *{"${target}::${as}"} = sub {
$me->build_variant_of($variable, @_);
};
};
@@ -176,7 +178,8 @@ your package.
use My::Variant;
my $new_variant_package = Variant( @variant_arguments );
-The package is now fully initialized and used.
+The package is now fully initialized and used. You can import the
+subroutine under a different name by specifying an C<as> argument.
=head2 Dynamic creation of variant packages
@@ -239,6 +242,19 @@ This method is provided for you. It will allow a user to C<use> your
package and receive a subroutine taking C<@arguments> defining the variant
and returning the name of the newly created variant package.
+The following options can be specified when importing:
+
+=over
+
+=item * B<as>
+
+ use Some::Variant::Package as => 'Foo';
+ my $variant_package = Foo( @arguments );
+
+Exports the generator subroutine under a different name than the default.
+
+=back
+
=head1 C<Package::Variant> METHODS
These methods are available on C<Package::Variant> itself.
--
libpackage-variant-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list