From: Alex J. G. BurzyƄski Date: Fri, 26 Aug 2011 09:00:56 +0000 (+0200) Subject: more readable subconstructor handling for BUILDALL X-Git-Tag: v0.009011~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=06c4d037a4df6e38e96aa0ff0a3cb50ab6966955;p=gitmo%2FMoo.git more readable subconstructor handling for BUILDALL --- diff --git a/lib/Method/Generate/BuildAll.pm b/lib/Method/Generate/BuildAll.pm index b4aa1fb..ad66d69 100644 --- a/lib/Method/Generate/BuildAll.pm +++ b/lib/Method/Generate/BuildAll.pm @@ -10,16 +10,19 @@ use B 'perlstring'; sub generate_method { my ($self, $into) = @_; quote_sub "${into}::BUILDALL", join '', + $self->_handle_subbuild($into), qq{ my \$self = shift;\n}, - qq{ my \$class = ref \$self;\n}, - ' if ('. perlstring($into) ." ne \$class) {\n", - qq{ return \$self->\${\\(\$Moo::Object::BUILD_MAKER->generate_method(\$class))}(\@_);\n}, - " } else {\n", - $self->buildall_body_for($into, '$self', '@_'), - " }\n", + $self->buildall_body_for($into, '$self', '@_'), qq{ return \$self\n}; } +sub _handle_subbuild { + my ($self, $into) = @_; + ' if (ref($_[0]) ne '.perlstring($into).') {'."\n". + ' return shift->Moo::Object::BUILDALL(@_)'.";\n". + ' }'."\n"; +} + sub buildall_body_for { my ($self, $into, $me, $args) = @_; my @builds =