fix error propagation when creating broken method modifiers
[gitmo/Role-Tiny.git] / lib / Role / Tiny.pm
index db9151e..8ddc074 100644 (file)
@@ -6,6 +6,9 @@ sub _getstash { \%{"$_[0]::"} }
 use strict;
 use warnings FATAL => 'all';
 
+our $VERSION = '1.000000'; # 1.0.0
+$VERSION = eval $VERSION;
+
 our %INFO;
 our %APPLIED_TO;
 our %COMPOSED;
@@ -37,7 +40,8 @@ sub _load_module {
 sub import {
   my $target = caller;
   my $me = shift;
-  strictures->import;
+  strict->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}::"} };
@@ -110,7 +114,7 @@ sub create_class_with_roles {
 
   foreach my $role (@roles) {
     _load_module($role);
-    die "${role} is not a Role::Tiny" unless my $info = $INFO{$role};
+    die "${role} is not a Role::Tiny" unless $INFO{$role};
   }
 
   if ($] >= 5.010) {
@@ -123,7 +127,7 @@ sub create_class_with_roles {
 
   *{_getglob("${new_name}::ISA")} = [ @composable, $superclass ];
 
-  my @info = map +($INFO{$_} ? $INFO{$_} : ()), @roles;
+  my @info = map $INFO{$_}, @roles;
 
   $me->_check_requires(
     $new_name, $compose_name,
@@ -154,11 +158,13 @@ sub _composable_package_for {
   ) {
     push @mod_base, "sub ${modified} { shift->next::method(\@_) }";
   }
+  my $e;
   {
     local $@;
     eval(my $code = join "\n", "package ${base_name};", @mod_base);
-    die "Evaling failed: $@\nTrying to eval:\n${code}" if $@;
+    $e = "Evaling failed: $@\nTrying to eval:\n${code}" if $@;
   }
+  die $e if $e;
   $me->_install_modifiers($composed_name, $modifiers);
   $COMPOSED{role}{$composed_name} = 1;
   return $composed_name;
@@ -248,7 +254,7 @@ sub does_role {
 
 =head1 NAME
 
-Role::Tiny - Roles. Like a nouvelle cusine portion size slice of Moose.
+Role::Tiny - Roles. Like a nouvelle cuisine portion size slice of Moose.
 
 =head1 SYNOPSIS
 
@@ -338,7 +344,7 @@ Returns true if class has been composed with role.
 This subroutine is also installed as ->does on any class a Role::Tiny is
 composed into unless that class already has an ->does method, so
 
-  if ($foo->does_role('Some::Role')) {
+  if ($foo->does('Some::Role')) {
     ...
   }
 
@@ -381,12 +387,38 @@ documentation.
 See L<< Class::Method::Modifiers/after method(s) => sub { ... } >> for full
 documentation.
 
-=head1 AUTHORS
+=head1 AUTHOR
+
+mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
+
+=head1 CONTRIBUTORS
+
+dg - David Leadbeater (cpan:DGL) <dgl@dgl.cx>
+
+frew - Arthur Axel "fREW" Schmidt (cpan:FREW) <frioux@gmail.com>
+
+hobbs - Andrew Rodland (cpan:ARODLAND) <arodland@cpan.org>
+
+jnap - John Napiorkowski (cpan:JJNAPIORK) <jjn1056@yahoo.com>
+
+ribasushi - Peter Rabbitson (cpan:RIBASUSHI) <ribasushi@cpan.org>
+
+chip - Chip Salzenberg (cpan:CHIPS) <chip@pobox.com>
+
+ajgb - Alex J. G. BurzyƄski (cpan:AJGB) <ajgb@cpan.org>
+
+doy - Jesse Luehrs (cpan:DOY) <doy at tozt dot net>
+
+perigrin - Chris Prather (cpan:PERIGRIN) <chris@prather.org>
+
+=head1 COPYRIGHT
 
-See L<Moo> for authors.
+Copyright (c) 2010-2012 the Role::Tiny L</AUTHOR> and L</CONTRIBUTORS>
+as listed above.
 
-=head1 COPYRIGHT AND LICENSE
+=head1 LICENSE
 
-See L<Moo> for the copyright and license.
+This library is free software and may be distributed under the same terms
+as perl itself.
 
 =cut