adjust for latest Role::Tiny
[gitmo/Moo.git] / lib / Moo.pm
index 6202171..1ccc972 100644 (file)
@@ -7,6 +7,18 @@ use B 'perlstring';
 our $VERSION = '0.009014'; # 0.9.13
 $VERSION = eval $VERSION;
 
+sub Moo::HandleMoose::AuthorityHack::DESTROY {
+  require Moo::HandleMoose;
+  Moo::HandleMoose->import;
+}
+
+if ($INC{"Moose.pm"}) {
+  require Moo::HandleMoose;
+  Moo::HandleMoose->import;
+} else {
+  $Moose::AUTHORITY = bless({}, 'Moo::HandleMoose::AuthorityHack');
+}
+
 our %MAKERS;
 
 sub import {
@@ -21,8 +33,7 @@ sub import {
   };
   *{_getglob("${target}::with")} = sub {
     require Moo::Role;
-    die "Only one role supported at a time by with" if @_ > 1;
-    Moo::Role->apply_role_to_package($target, $_[0]);
+    Moo::Role->apply_roles_to_package($target, $_[0]);
   };
   $MAKERS{$target} = {};
   *{_getglob("${target}::has")} = sub {
@@ -46,6 +57,9 @@ sub import {
       require Moo::Object; ('Moo::Object');
     } unless @{"${target}::ISA"};
   }
+  if ($INC{'Moo/HandleMoose.pm'}) {
+    Moo::HandleMoose::inject_fake_metaclass_for($target);
+  }
 }
 
 sub _constructor_maker_for {