From: Dave Rolsky Date: Sat, 21 Mar 2009 15:16:19 +0000 (-0500) Subject: make MMM::Destructor->is_needed a class method only X-Git-Tag: 0.72_01~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a7b097bb90026ae7af26dc9df800680c8b0d46ba;p=gitmo%2FMoose.git make MMM::Destructor->is_needed a class method only --- diff --git a/Changes b/Changes index c0c051c..beade47 100644 --- a/Changes +++ b/Changes @@ -45,6 +45,9 @@ Revision history for Perl extension Moose - The long-deprecated intialize_body method has been removed (yes, spelled like that). + * Moose::Meta::Method::Destructor + - This is_needed method is now always a class method. + 0.72 Mon, February 23, 2009 * Moose::Object * Moose::Meta::Method::Constructor diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm index 2be0b2d..d8f21a2 100644 --- a/lib/Moose/Meta/Method/Destructor.pm +++ b/lib/Moose/Meta/Method/Destructor.pm @@ -50,16 +50,15 @@ sub associated_metaclass { (shift)->{'associated_metaclass'} } ## method -sub is_needed { - my $self = shift; - # if called as a class method - # then must pass in a class name - unless (blessed $self) { - (blessed $_[0] && $_[0]->isa('Class::MOP::Class')) - || $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 +sub is_needed { + my $self = shift; + my $metaclass = shift; + + ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') ) + || $self->throw_error( + "The is_needed method expected a metaclass object as its arugment"); + + return $metaclass->meta->can('DEMOLISH'); } sub initialize_body {