I found that if a subclass adds a trigger, then the modifiers of the method from the base class do not start. This seems to be a Fly's mistake, or at least unintuitive. Here is my example:
package Foo {
use Moose;
has 'foo' => (
is => 'rw',
isa => 'Str',
);
before 'foo' => sub {
warn "before foo";
};
};
package FooChild {
use Moose;
extends 'Foo';
has '+foo' => ( trigger => \&my_trigger, );
sub my_trigger {
warn 'this is my_trigger';
}
};
my $fc = FooChild->new();
$fc->foo(10);
If you run this example, only the warning "this my_trigger" is triggered, and the "before" modifier is ignored. I am using Perl 5.14.2 with Moose 2.0402.
Is this the right behavior? This does not seem correct, especially since the trigger fires after the trigger is defined directly in the base class.
source
share