0.9.5 release commit
[gitmo/Moo.git] / lib / Moo / Role.pm
index a8af3cf..a8c2083 100644 (file)
@@ -26,8 +26,8 @@ sub import {
 }
 
 sub apply_role_to_package {
-  my ($me, $role, $to) = @_;
-  $me->SUPER::apply_role_to_package($role, $to);
+  my ($me, $to, $role) = @_;
+  $me->SUPER::apply_role_to_package($to, $role);
   $me->_handle_constructor($to, $INFO{$role}{attributes});
 }
 
@@ -46,7 +46,7 @@ sub create_class_with_roles {
   }
 
   $me->_handle_constructor(
-    $new_name, { map %{$INFO{$_}{attributes}||{}}, @roles }
+    $new_name, { map %{$INFO{$_}{attributes}||{}}, @roles }, $superclass
   );
 
   return $new_name;
@@ -58,14 +58,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 +73,9 @@ sub _handle_constructor {
 
 1;
 
-=pod
+=head1 NAME
+
+Moo::Role - Minimal Object Orientation support for Roles
 
 =head1 SYNOPSIS