Subject: | attributes with lazy/lazy_build become 'required', but docs don't mention this. |
See the attached script; it shows that lazy attributes become 'required'
according to the meta code. However, this isn't mentioned in the docs:
http://search.cpan.org/~drolsky/Moose-0.79/lib/Moose/Meta/Attribute.pm#Creation
http://search.cpan.org/~drolsky/Moose-0.79/lib/Moose/Manual/Attributes.pod#Laziness_and_lazy_build
I'm not sure what a better wording would be, but stating explicitly that
this generates the equivalent of C<required => 1> is probably a good idea
Subject: | z.pl |
package Foo;
use Moose;
has normal => (
is => 'ro',
default => 1,
);
has lazy => (
is => 'ro',
lazy_build => 1,
);
has must => (
is => 'ro',
default => 1,
required => 1,
);
sub _build_lazy { 1 };
package main;
my $foo = Foo->new;
print map { $_->reader . " is required\n" }
grep { $_->is_required and not $_->is_lazy } $foo->meta->get_all_attributes;
__END__
$ perl tmp/z.pl
lazy is required
must is required