Subject: | trigger not called when default is called |
The docs indicate that a trigger is called whenever an attribute is set. This doesn't seem to be the case when the attribute is set via the default coderef:
The following code illustrates this:
Show quoted text
package Foo;
use latest;
use Moo;
has a => (
is => 'rw',
trigger => sub {
say 'trigger';
},
default => sub { say 'default' },
);
}
Foo->new->a;
Show quoted text
The output is:
---------
default
---------
I expected:
---------
default
trigger
---------
It doesn't matter whether or not the attribute has the 'lazy' option set.
The following code illustrates this:
Show quoted text
======================
{package Foo;
use latest;
use Moo;
has a => (
is => 'rw',
trigger => sub {
say 'trigger';
},
default => sub { say 'default' },
);
}
Foo->new->a;
Show quoted text
======================
The output is:
---------
default
---------
I expected:
---------
default
trigger
---------
It doesn't matter whether or not the attribute has the 'lazy' option set.