in reply to Moose: Where to define a method required by an attribute trait?
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', );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moose: Where to define a method required by an attribute trait?
by maxhq (Novice) on Apr 29, 2010 at 09:10 UTC | |
by stvn (Monsignor) on Apr 29, 2010 at 11:45 UTC | |
by maxhq (Novice) on Apr 29, 2010 at 17:56 UTC | |
by stvn (Monsignor) on Apr 30, 2010 at 19:31 UTC | |
by maxhq (Novice) on May 04, 2010 at 09:38 UTC |