From: Dagfinn Ilmari Mannsåker Date: Sat, 14 Jul 2012 15:42:21 +0000 (+0100) Subject: Factor 'extends' guts into separate method X-Git-Tag: v0.091012~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=48a5142859db8a5a61d23a60f91a588d2e0ee620;p=gitmo%2FMoo.git Factor 'extends' guts into separate method --- diff --git a/lib/Moo.pm b/lib/Moo.pm index 3e256e2..fe7bdae 100644 --- a/lib/Moo.pm +++ b/lib/Moo.pm @@ -25,18 +25,7 @@ sub import { return if $MAKERS{$target}; # already exported into this package $MAKERS{$target} = {}; _install_tracked $target => extends => sub { - _load_module($_) for @_; - # Can't do *{...} = \@_ or 5.10.0's mro.pm stops seeing @ISA - @{*{_getglob("${target}::ISA")}{ARRAY}} = @_; - if (my $old = delete $Moo::MAKERS{$target}{constructor}) { - delete _getstash($target)->{new}; - Moo->_constructor_maker_for($target) - ->register_attribute_specs(%{$old->all_attribute_specs}); - } - no warnings 'once'; # piss off. -- mst - $Moo::HandleMoose::MOUSE{$target} = [ - grep defined, map Mouse::Util::find_meta($_), @_ - ] if $INC{"Mouse.pm"}; + $class->_set_superclasses($target, @_); $class->_maybe_reset_handlemoose($target); return; }; @@ -77,6 +66,23 @@ sub unimport { _unimport_coderefs($target, $MAKERS{$target}); } +sub _set_superclasses { + my $class = shift; + my $target = shift; + _load_module($_) for @_; + # Can't do *{...} = \@_ or 5.10.0's mro.pm stops seeing @ISA + @{*{_getglob("${target}::ISA")}{ARRAY}} = @_; + if (my $old = delete $Moo::MAKERS{$target}{constructor}) { + delete _getstash($target)->{new}; + Moo->_constructor_maker_for($target) + ->register_attribute_specs(%{$old->all_attribute_specs}); + } + no warnings 'once'; # piss off. -- mst + $Moo::HandleMoose::MOUSE{$target} = [ + grep defined, map Mouse::Util::find_meta($_), @_ + ] if $INC{"Mouse.pm"}; +} + sub _maybe_reset_handlemoose { my ($class, $target) = @_; if ($INC{"Moo/HandleMoose.pm"}) {