From: Matt S Trout Date: Sat, 25 Aug 2012 20:13:51 +0000 (+0000) Subject: no_import and make_variant options X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fextra_options;p=p5sagit%2FPackage-Variant.git no_import and make_variant options --- diff --git a/lib/Package/Variant.pm b/lib/Package/Variant.pm index 0b75507..b9ed5a6 100644 --- a/lib/Package/Variant.pm +++ b/lib/Package/Variant.pm @@ -64,6 +64,7 @@ sub import { $Variable{$variable} = { anon => $anon, args => { + make_variant => 'make_variant', %args, importing => $me->$sanitize_importing($args{importing}), }, @@ -79,7 +80,7 @@ sub import { *{"${target}::${as}"} = sub { $me->build_variant_of($variable, @_); }; - }; + } unless $args{no_import}; my $subs = $Variable{$variable}{subs}; foreach my $name (keys %$subs) { *{"${target}::${name}"} = sub { @@ -108,7 +109,7 @@ sub build_variant_of { no strict 'refs'; *$full_name = $ref; }; - $variable->make_variant($variant_name, @args); + $variable->${\$Variable{$variable}{args}{make_variant}}($variant_name, @args); return $variant_name; }