X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FRole%2FTiny.pm;h=3062e65562e24031245c960ca5f1380de7e6f808;hb=76acfa6c8aca484921a7fd50332d85e366d2b30a;hp=07ea94a390327b95350da398bba51f95f7c9d5a5;hpb=fa89d58252a80231301b8c7f05ec5a8e21991d68;p=gitmo%2FRole-Tiny.git diff --git a/lib/Role/Tiny.pm b/lib/Role/Tiny.pm index 07ea94a..3062e65 100644 --- a/lib/Role/Tiny.pm +++ b/lib/Role/Tiny.pm @@ -6,7 +6,7 @@ sub _getstash { \%{"$_[0]::"} } use strict; use warnings FATAL => 'all'; -our $VERSION = '1.001005'; # 1.1.5 +our $VERSION = '1.002002'; # 1.2.2 $VERSION = eval $VERSION; our %INFO; @@ -45,7 +45,7 @@ sub import { warnings->import(FATAL => 'all'); return if $INFO{$target}; # already exported into this package # get symbol table reference - my $stash = do { no strict 'refs'; \%{"${target}::"} }; + my $stash = _getstash($target); # install before/after/around subs foreach my $type (qw(before after around)) { *{_getglob "${target}::${type}"} = sub { @@ -250,7 +250,7 @@ sub _concrete_methods_of { my ($me, $role) = @_; my $info = $INFO{$role}; # grab role symbol table - my $stash = do { no strict 'refs'; \%{"${role}::"}}; + my $stash = _getstash($role); # reverse so our keys become the values (captured coderefs) in case # they got copied or re-used since my $not_methods = { reverse %{$info->{not_methods}||{}} }; @@ -278,7 +278,7 @@ sub _install_methods { my $methods = $me->_concrete_methods_of($role); # grab target symbol table - my $stash = do { no strict 'refs'; \%{"${to}::"}}; + my $stash = _getstash($to); # determine already extant methods of target my %has_methods; @@ -321,7 +321,7 @@ sub _install_does { # add does() only if they don't have one *{_getglob "${to}::does"} = \&does_role unless $to->can('does'); - return if ($to->can('DOES') and $to->can('DOES') != UNIVERSAL->can('DOES')); + return if ($to->can('DOES') and $to->can('DOES') != (UNIVERSAL->can('DOES') || 0)); my $existing = $to->can('DOES') || $to->can('isa') || $FALLBACK; my $new_sub = sub {