1 package Method::Generate::BuildAll;
4 use base qw(Moo::Object);
11 my ($self, $into) = @_;
12 quote_sub "${into}::BUILDALL", join '',
13 $self->_handle_subbuild($into),
14 qq{ my \$self = shift;\n},
15 $self->buildall_body_for($into, '$self', '@_'),
19 sub _handle_subbuild {
20 my ($self, $into) = @_;
21 ' if (ref($_[0]) ne '.perlstring($into).') {'."\n".
22 ' return shift->Moo::Object::BUILDALL(@_)'.";\n".
26 sub buildall_body_for {
27 my ($self, $into, $me, $args) = @_;
29 grep *{_getglob($_)}{CODE},
31 reverse @{mro::get_linear_isa($into)};
32 join '', map qq{ ${me}->${_}(${args});\n}, @builds;