I think perhaps you want something that ends up looking more like this:
You can read the Moose::Manual entry on attribute traits to see how that is accomplished, it is fairly straightforward and common use of attribute traits (to add more options to has).has testdir => ( traits => ['DirOption'], isa => 'Str', is => 'rw', rootdir => '/home/paulatreides', );
As for your _build_rootdir approach, you could use MooseX::Role::Parameterized for this. In that case it will look more like this instead
This is a less common way to use attribute traits, but it too should work.has testdir => ( traits => [ 'DirOption' => { rootdir => '/home/paulatreides' } + ], isa => 'Str', is => 'rw', );
In reply to Re: Moose: Where to define a method required by an attribute trait?
by stvn
in thread Moose: Where to define a method required by an attribute trait?
by maxhq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |