Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 82310
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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.

For what it's worth, the trigger is also not called while using a builder either via setting is => 'lazy', or explicitly via the builder option.
This behavior mirrors Moose, so I'd say all that is needed is a clarification in the docs.
I've added a clarification to this in the docs, which will be in the next release.
Moo 1.00100 includes the doc changes clarifying this.