subconstructor handling for Moose classes
Matt S Trout [Tue, 26 Jun 2012 17:30:44 +0000 (17:30 +0000)]
Changes
lib/Moo.pm

diff --git a/Changes b/Changes
index 508c4a3..cef0abb 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+  - subconstructor handling for Moose classes
+
 0.091009 - 2012-06-20
   - squelch redefine warnings in the coderef installation code
 
index 6aa9cd2..2034459 100644 (file)
@@ -137,6 +137,8 @@ sub _constructor_maker_for {
           '      if ($Moo::MAKERS{$class}) {'."\n"
           .'        '.$class.'->_constructor_maker_for($class,'.perlstring($target).');'."\n"
           .'        return $class->new(@_)'.";\n"
+          .'      } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {'."\n"
+          .'        return $meta->new_object(@_);'."\n"
           .'      }'."\n"
         ),
       )