X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FDestructor.pm;h=d8f21a2ee6b93f303458f9980a802b0e8a9cbf98;hb=5f43e0cffb2643c6e8a0624b309a0896e820e7ad;hp=2be0b2d68e01bbbbf5059447ec521b0ce70d2097;hpb=9409e92e75a6e1060eb3d0adcfc7965713d3d776;p=gitmo%2FMoose.git 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 {