@{*{_getglob("${target}::ISA")}{ARRAY}} = @_;
};
*{_getglob("${target}::with")} = sub {
- require Moo::Role;
+ { local $@; require Moo::Role; }
die "Only one role supported at a time by with" if @_ > 1;
Moo::Role->apply_role_to_package($target, $_[0]);
};
*{_getglob("${target}::has")} = sub {
my ($name, %spec) = @_;
($MAKERS{$target}{accessor} ||= do {
- require Method::Generate::Accessor;
+ { local $@; require Method::Generate::Accessor; }
Method::Generate::Accessor->new
})->generate_method($target, $name, \%spec);
$class->_constructor_maker_for($target)
};
foreach my $type (qw(before after around)) {
*{_getglob "${target}::${type}"} = sub {
- require Class::Method::Modifiers;
+ { local $@; require Class::Method::Modifiers; }
_install_modifier($target, $type, @_);
};
}
{
no strict 'refs';
@{"${target}::ISA"} = do {
- require Moo::Object; ('Moo::Object');
+ {; local $@; require Moo::Object; } ('Moo::Object');
} unless @{"${target}::ISA"};
}
}
my ($class, $target, $select_super) = @_;
return unless $MAKERS{$target};
$MAKERS{$target}{constructor} ||= do {
- require Method::Generate::Constructor;
- require Sub::Defer;
+ {
+ local $@;
+ require Method::Generate::Constructor;
+ require Sub::Defer;
+ }
my ($moo_constructor, $con);
if ($select_super && $MAKERS{$select_super}) {
->new(
package => $target,
accessor_generator => do {
- require Method::Generate::Accessor;
+ { local $@; require Method::Generate::Accessor; }
Method::Generate::Accessor->new;
},
construction_string => (
C<BUILD> method from parent down to child after the object has been
instantiated. Typically this is used for object validation or possibly logging.
+=head2 DESTROY
+
+If you have a C<DEMOLISH> method anywhere in your inheritance hierarchy,
+a C<DESTROY> method is created on first object construction which will call
+C<< $instance->DEMOLISH($in_global_destruction) >> for each C<DEMOLISH>
+method from child upwards to parents.
+
+Note that the C<DESTROY> method is created on first construction of an object
+of your class in order to not add overhead to classes without C<DEMOLISH>
+methods; this may prove slightly surprising if you try and define your own.
+
=head2 does
if ($foo->does('Some::Role1')) {