use strict;
use warnings;
-use Moose::Meta::Class;
-use metaclass 'Moose::Meta::Class';
+use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
+use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
use Carp 'confess';
-our $VERSION = '0.09';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:STEVAN';
sub new {
return unless $_[0]->can('BUILD');
my ($self, $params) = @_;
foreach my $method (reverse $self->meta->find_all_methods_by_name('BUILD')) {
- $method->{code}->($self, $params);
+ $method->{code}->body->($self, $params);
}
}
sub DEMOLISHALL {
- # NOTE: we ask Perl if we even
- # need to do this first, to avoid
- # extra meta level calls
- return unless $_[0]->can('DEMOLISH');
my $self = shift;
foreach my $method ($self->meta->find_all_methods_by_name('DEMOLISH')) {
- $method->{code}->($self);
- }
+ $method->{code}->body->($self);
+ }
}
-sub DESTROY { goto &DEMOLISHALL }
+sub DESTROY {
+ # NOTE: we ask Perl if we even
+ # need to do this first, to avoid
+ # extra meta level calls
+ return unless $_[0]->can('DEMOLISH');
+ # if we have an exception here ...
+ if ($@) {
+ # localize the $@ ...
+ local $@;
+ # run DEMOLISHALL ourselves, ...
+ $_[0]->DEMOLISHALL;
+ # and return ...
+ return;
+ }
+ # otherwise it is normal destruction
+ $_[0]->DEMOLISHALL;
+}
# new does() methods will be created
# as approiate see Moose::Meta::Role
|| confess "You much supply a role name to does()";
my $meta = $self->meta;
foreach my $class ($meta->class_precedence_list) {
+ my $m = $meta->initialize($class);
return 1
- if $meta->initialize($class)->does_role($role_name);
+ if $m->can('does_role') && $m->does_role($role_name);
}
return 0;
}
sub dump {
my $self = shift;
require Data::Dumper;
- $Data::Dumper::Maxdepth = shift if @_;
+ local $Data::Dumper::Maxdepth = shift if @_;
Data::Dumper::Dumper $self;
}
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
-=cut
\ No newline at end of file
+=cut