1 package Method::Generate::DemolishAll;
4 use base qw(Moo::Object);
10 my ($self, $into) = @_;
11 quote_sub "${into}::DEMOLISHALL", join '',
12 $self->_handle_subdemolish($into),
13 qq{ my \$self = shift;\n},
14 $self->demolishall_body_for($into, '$self', '@_'),
16 quote_sub "${into}::DESTROY", join '',
23 $self->DEMOLISHALL($Moo::_Utils::_in_global_destruction);
29 die $e if $e; # rethrow
33 sub demolishall_body_for {
34 my ($self, $into, $me, $args) = @_;
36 grep *{_getglob($_)}{CODE},
38 @{Moo::_Utils::_get_linear_isa($into)};
39 join '', map qq{ ${me}->${_}(${args});\n}, @demolishers;
42 sub _handle_subdemolish {
43 my ($self, $into) = @_;
44 ' if (ref($_[0]) ne '.perlstring($into).') {'."\n".
45 ' return shift->Moo::Object::DEMOLISHALL(@_)'.";\n".