summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-06-14 10:46:46 -0500
committerJesse Luehrs <doy@tozt.net>2011-06-14 10:46:46 -0500
commit3edca453f642917f53c6fbfa59683fd70204813d (patch)
tree4671fb39b35c8b218e3b53d074bee650e9c69496 /lib
parent08127efc8a27fca6d6126229fa5c2954bab43843 (diff)
downloadsub-exporter-declare-3edca453f642917f53c6fbfa59683fd70204813d.tar.gz
sub-exporter-declare-3edca453f642917f53c6fbfa59683fd70204813d.zip
initial sketch
Diffstat (limited to 'lib')
-rw-r--r--lib/Sub/Exporter/Sugar.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Sub/Exporter/Sugar.pm b/lib/Sub/Exporter/Sugar.pm
index e69de29..2370279 100644
--- a/lib/Sub/Exporter/Sugar.pm
+++ b/lib/Sub/Exporter/Sugar.pm
@@ -0,0 +1,38 @@
+package Sub::Exporter::Sugar;
+use strict;
+use warnings;
+
+my %EXPORT_DATA;
+
+use Sub::Exporter 'build_exporter', -setup => {
+ exports => [qw(export export_default), import => \&import_generator],
+ groups => {
+ default => [qw(export export_default import)],
+ },
+};
+
+sub export {
+ my @exports = @_;
+ my $caller = caller;
+ $EXPORT_DATA{$caller} ||= {};
+ push @{ $EXPORT_DATA{$caller}->{exports} ||= [] }, @exports;
+}
+
+sub export_default {
+ my @exports = @_;
+ my $caller = caller;
+ $EXPORT_DATA{$caller} ||= {};
+ push @{ $EXPORT_DATA{$caller}->{exports} ||= [] }, @exports;
+ push @{ $EXPORT_DATA{$caller}->{groups}{default} ||= [] }, @exports;
+}
+
+sub import_generator {
+ my ($class, $name, $arg, $col) = @_;
+ return sub {
+ my ($package) = @_;
+ my $import = build_exporter($EXPORT_DATA{$package});
+ goto $import;
+ };
+}
+
+1;