package Parent; use Moose; has 'knibbel' => ( is => 'rw', isa => 'HashRef[Maybe[Value]]', lazy_build => 1, ); has 'knabbel' => ( is => 'rw', isa => 'ArrayRef[Maybe[Value]]', lazy_build => 1, ); sub BUILD { my $self = shift; my $meta = $self->meta; print("BUILD called for " . __PACKAGE__ . "\n"); no strict; foreach my $attribute ($meta->get_attribute_list) { print("Creating builder for attribute [$attribute]\n"); *{__PACKAGE__ . '::_build_' . $attribute} = sub { my $self = shift; my $meta = $self->meta; my $fropsel = $meta->get_attribute($attribute); if ($fropsel->type_constraint->name =~ /^ArrayRef/) { return []; } if ($fropsel->type_constraint->name =~ /^HashRef/) { return {}; } }; } use strict; } 1;