X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FPackage%2FVariant.pm;h=a05af5b129c351385295426e8602cb6a071f7edc;hb=4e3b81776277e0dc30ed03205a9fee166a98d9fa;hp=4aeda2a62b297b04e047428f450db014acc9f8ab;hpb=d61014ce3f63d541db3164e5c743e32db2bab238;p=p5sagit%2FPackage-Variant.git diff --git a/lib/Package/Variant.pm b/lib/Package/Variant.pm index 4aeda2a..a05af5b 100644 --- a/lib/Package/Variant.pm +++ b/lib/Package/Variant.pm @@ -5,7 +5,7 @@ use Import::Into; use Module::Runtime qw(require_module); use Carp qw(croak); -our $VERSION = '1.001004'; # 1.1.4 +our $VERSION = '1.002000'; # 1.2.0 $VERSION = eval $VERSION; @@ -87,7 +87,11 @@ sub import { } *{"${variable}::install"} = sub { goto &{$Variable{$variable}{install}}; - } + }; + *{"${variable}::build_variant"} = sub { + shift; + $me->build_variant_of($variable, @_); + }; } sub build_variant_of { @@ -130,7 +134,7 @@ Package::Variant - Parameterizable packages # what modules to 'use' importing => ['Moo::Role'], # proxied subroutines - subs => [ qw(has around before after with) ], + subs => [ qw(has around before after with) ]; sub make_variant { my ($class, $target_package, %arguments) = @_; @@ -328,6 +332,16 @@ Exports the generator subroutine under a different name than the default. =back +=head2 build_variant + + use Some::Variant::Package (); + my $variant_package = Some::Variant::Package->build_variant( @arguments ); + +This method is provided for you. It will generate a variant package +and return its name, just like the generator sub provided by +L. This allows you to avoid importing anything into the +consuming package. + =head1 C METHODS These methods are available on C itself. @@ -374,6 +388,8 @@ mst - Matt S. Trout (cpan:MSTROUT) phaylon - Robert Sedlacek (cpan:PHAYLON) +haarg - Graham Knop (cpan:HAARG) + =head1 COPYRIGHT Copyright (c) 2010-2012 the C L and