I have the following five Moose attributes:
has ['summary_file', 'html_file', 'url1', 'url2', 'txt_file'] => (
is => 'rw',
isa => 'Str',
required => 0,
lazy => 1,
default => sub { confess "Attribute not set"; },
);
I would like to:
- Make each of them use its own builder (e.g. set
'summary_file'use_build_summary_file, etc.) - Make the default
confesssub state which (uninitialized) attribute was called (e.g."Attribute 'summary_file' not set").
I can accomplish the above by writing five separate has‘s, but perhaps there’s a more compact way?
You could do something the like following (new working example after your “does not work” comment below):
Note that you cannot specify both a
defaultand abuilder.@Oesor points out in a comment something I forgot: