From: Matt S Trout Date: Tue, 16 Nov 2010 00:46:08 +0000 (+0000) Subject: guard against double import X-Git-Tag: 0.009001~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ba114550da04faf77252207e6df621c37d07da7;p=gitmo%2FRole-Tiny.git guard against double import --- diff --git a/lib/Moo.pm b/lib/Moo.pm index 2f27387..cc8de95 100644 --- a/lib/Moo.pm +++ b/lib/Moo.pm @@ -12,6 +12,7 @@ sub import { my $target = caller; my $class = shift; strictures->import; + return if $MAKERS{$target}; # already exported into this package *{_getglob("${target}::extends")} = sub { _load_module($_) for @_; *{_getglob("${target}::ISA")} = \@_; diff --git a/lib/Moo/Role.pm b/lib/Moo/Role.pm index 7a7cae1..c27c025 100644 --- a/lib/Moo/Role.pm +++ b/lib/Moo/Role.pm @@ -11,6 +11,7 @@ our %INFO; sub import { my $target = caller; strictures->import; + return if $INFO{$target}; # already exported into this package # get symbol table reference my $stash = do { no strict 'refs'; \%{"${target}::"} }; *{_getglob "${target}::has"} = sub { diff --git a/lib/Role/Tiny.pm b/lib/Role/Tiny.pm index ebf9807..844272f 100644 --- a/lib/Role/Tiny.pm +++ b/lib/Role/Tiny.pm @@ -20,6 +20,7 @@ sub import { my $target = caller; my $me = $_[0]; strictures->import; + return if $INFO{$target}; # already exported into this package # get symbol table reference my $stash = do { no strict 'refs'; \%{"${target}::"} }; # install before/after/around subs