X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FDestructor.pm;h=c11ec4d69ab6272944504166ace2f03c8ddb4650;hb=4da72c45030b36f43e7b9bfb15c38276f14db3a6;hp=b30db6a4f80ead94452a9f52f47de9968878c662;hpb=75b9541431131c67521bd1ec75df80c9707bd719;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index b30db6a..c11ec4d 100644 --- a/lib/Moose/Meta/Method/Destructor.pm +++ b/lib/Moose/Meta/Method/Destructor.pm @@ -4,10 +4,9 @@ package Moose::Meta::Method::Destructor; use strict; use warnings; -use Carp 'confess'; use Scalar::Util 'blessed', 'weaken'; -our $VERSION = '0.55_01'; +our $VERSION = '0.68'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -18,12 +17,12 @@ sub new { my $class = shift; my %options = @_; - (exists $options{options} && ref $options{options} eq 'HASH') - || confess "You must pass a hash of options"; - + (ref $options{options} eq 'HASH') + || $class->throw_error("You must pass a hash of options", data => $options{options}); + ($options{package_name} && $options{name}) - || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"; - + || $class->throw_error("You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"); + my $self = bless { # from our superclass 'body' => undef, @@ -57,7 +56,7 @@ sub is_needed { # then must pass in a class name unless (blessed $self) { (blessed $_[0] && $_[0]->isa('Class::MOP::Class')) - || confess "When calling is_needed as a class method you must pass a class name"; + || $self->throw_error("When calling is_needed as a class method you must pass a class name"); return $_[0]->meta->can('DEMOLISH'); } defined $self->{'body'} ? 1 : 0 @@ -89,11 +88,11 @@ sub initialize_body { $source .= ";\n" . '}'; warn $source if $self->options->{debug}; - my $code; - { - $code = eval $source; - confess "Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@" 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; } @@ -111,7 +110,7 @@ Moose::Meta::Method::Destructor - Method Meta Object for destructors =head1 DESCRIPTION This is a subclass of L which handles -constructing an approprate Destructor method. This is primarily +constructing an appropriate Destructor method. This is primarily used in the making of immutable metaclasses, otherwise it is not particularly useful. @@ -141,7 +140,7 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2008 by Infinity Interactive, Inc. +Copyright 2006-2009 by Infinity Interactive, Inc. L