From: Yuval Kogman Date: Sat, 17 Jan 2009 22:03:26 +0000 (+0000) Subject: use _compile_code in Destructor X-Git-Tag: 0.65~20^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=497442e83fa9fbb2a42c38326f41f07de558b767;p=gitmo%2FMoose.git use _compile_code in Destructor --- diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index e2beb45..392dd68 100644 --- a/lib/Moose/Meta/Method/Destructor.pm +++ b/lib/Moose/Meta/Method/Destructor.pm @@ -88,11 +88,11 @@ sub initialize_body { $source .= ";\n" . '}'; warn $source if $self->options->{debug}; - my $code; - { - $code = eval $source; - $self->throw_error("Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source) if $@; - } + my $code = $self->_compile_code( + environment => {}, + code => $source, + ) or $self->throw_error("Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source); + $self->{'body'} = $code; }