replace open-coded stash access with _getstash()
[gitmo/Role-Tiny.git] / lib / Role / Tiny.pm
index 07ea94a..3062e65 100644 (file)
@@ -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 {