use Carp 'confess';
use Scalar::Util 'blessed';
-use Sub::Name 'subname';
-our $VERSION = '0.06';
+our $VERSION = '0.63';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Object';
$metaclass->add_method(
$options{constructor_name},
$constructor_class->new(
- options => \%options,
- metaclass => $metaclass,
- is_inline => 1,
+ options => \%options,
+ metaclass => $metaclass,
+ is_inline => 1,
+ package_name => $metaclass->name,
+ name => $options{constructor_name}
)
) unless $metaclass->has_method($options{constructor_name});
}
my $destructor_class = $options{destructor_class};
- my $destructor = $destructor_class->new(
- options => \%options,
- metaclass => $metaclass,
- );
-
- $metaclass->add_method('DESTROY' => $destructor)
- # NOTE:
- # we allow the destructor to determine
- # if it is needed or not, it can perform
- # all sorts of checks because it has the
- # metaclass instance
- if $destructor->is_needed;
+ # NOTE:
+ # we allow the destructor to determine
+ # if it is needed or not before we actually
+ # create the destructor too
+ # - SL
+ if ($destructor_class->is_needed($metaclass)) {
+ my $destructor = $destructor_class->new(
+ options => \%options,
+ metaclass => $metaclass,
+ package_name => $metaclass->name,
+ name => 'DESTROY'
+ );
+
+ $metaclass->add_method('DESTROY' => $destructor)
+ # NOTE:
+ # we allow the destructor to determine
+ # if it is needed or not, it can perform
+ # all sorts of checks because it has the
+ # metaclass instance
+ if $destructor->is_needed;
+ }
}
my $memoized_methods = $self->options->{memoize};