bump version for release
[gitmo/Role-Tiny.git] / lib / Role / Tiny.pm
index 6e3a70a..6620964 100644 (file)
@@ -6,7 +6,7 @@ sub _getstash { \%{"$_[0]::"} }
 use strict;
 use warnings FATAL => 'all';
 
-our $VERSION = '1.001002'; # 1.1.2
+our $VERSION = '1.001005'; # 1.1.5
 $VERSION = eval $VERSION;
 
 our %INFO;
@@ -188,7 +188,14 @@ sub apply_roles_to_package {
         } keys %conflicts;
     die $fail;
   }
-  delete $INFO{$to}{methods}; # reset since we're about to add methods
+
+  # the if guard here is essential since otherwise we accidentally create
+  # a $INFO for something that isn't a Role::Tiny (or Moo::Role) because
+  # autovivification hates us and wants us to die()
+  if ($INFO{$to}) {
+    delete $INFO{$to}{methods}; # reset since we're about to add methods
+  }
+
   $me->apply_role_to_package($to, $_) for @roles;
   $APPLIED_TO{$to}{join('|',@roles)} = 1;
 }
@@ -252,7 +259,7 @@ sub _concrete_methods_of {
   my $stash = do { no strict 'refs'; \%{"${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}} };
+  my $not_methods = { reverse %{$info->{not_methods}||{}} };
   $info->{methods} ||= +{
     # grab all code entries that aren't in the not_methods list
     map {
@@ -310,7 +317,15 @@ sub _install_single_modifier {
 
 sub does_role {
   my ($proto, $role) = @_;
-  return exists $APPLIED_TO{ref($proto)||$proto}{$role};
+  if ($] >= 5.010) {
+    require mro;
+  } else {
+    require MRO::Compat;
+  }
+  foreach my $class (@{mro::get_linear_isa(ref($proto)||$proto)}) {
+    return 1 if exists $APPLIED_TO{$class}{$role};
+  }
+  return 0;
 }
 
 1;
@@ -522,6 +537,8 @@ perigrin - Chris Prather (cpan:PERIGRIN) <chris@prather.org>
 
 Mithaldu - Christian Walde (cpan:MITHALDU) <walde.christian@googlemail.com>
 
+ilmari - Dagfinn Ilmari MannsÃ¥ker (cpan:ILMARI) <ilmari@ilmari.org>
+
 =head1 COPYRIGHT
 
 Copyright (c) 2010-2012 the Role::Tiny L</AUTHOR> and L</CONTRIBUTORS>