revert local $\@ around require to avoid eating errors
[gitmo/Moo.git] / lib / Moo / Role.pm
index 6710384..5b3761f 100644 (file)
@@ -34,7 +34,10 @@ sub apply_role_to_package {
 sub create_class_with_roles {
   my ($me, $superclass, @roles) = @_;
 
-  my $new_name = join('+', $superclass, my $compose_name = join '+', @roles);
+  my $new_name = join(
+    '__WITH__', $superclass, my $compose_name = join '__AND__', @roles
+  );
+
   return $new_name if $Role::Tiny::COMPOSED{class}{$new_name};
 
   require Sub::Quote;
@@ -45,8 +48,10 @@ sub create_class_with_roles {
     die "${role} is not a Role::Tiny" unless my $info = $INFO{$role};
   }
 
+  $Moo::MAKERS{$new_name} = {};
+
   $me->_handle_constructor(
-    $new_name, { map %{$INFO{$_}{attributes}||{}}, @roles }
+    $new_name, { map %{$INFO{$_}{attributes}||{}}, @roles }, $superclass
   );
 
   return $new_name;
@@ -58,14 +63,14 @@ sub _install_single_modifier {
 }
 
 sub _handle_constructor {
-  my ($me, $to, $attr_info) = @_;
+  my ($me, $to, $attr_info, $superclass) = @_;
   return unless $attr_info && keys %$attr_info;
   if ($INFO{$to}) {
     @{$INFO{$to}{attributes}||={}}{keys %$attr_info} = values %$attr_info;
   } else {
     # only fiddle with the constructor if the target is a Moo class
     if ($INC{"Moo.pm"}
-        and my $con = Moo->_constructor_maker_for($to)) {
+        and my $con = Moo->_constructor_maker_for($to, $superclass)) {
       $con->register_attribute_specs(%$attr_info);
     }
   }
@@ -73,7 +78,9 @@ sub _handle_constructor {
 
 1;
 
-=pod
+=head1 NAME
+
+Moo::Role - Minimal Object Orientation support for Roles
 
 =head1 SYNOPSIS
 
@@ -123,3 +130,13 @@ imported by this module.
 
 Declares an attribute for the class to be composed into.  See
 L<Moo/has> for all options.
+
+=head1 AUTHORS
+
+See L<Moo> for authors.
+
+=head1 COPYRIGHT AND LICENSE
+
+See L<Moo> for the copyright and license.
+
+=cut