in reply to Re: constraining the keys of a HashRef in Moose
in thread constraining the keys of a HashRef in Moose
Hi Tobyink,
thanks for your help earlier and for recommending the very useful Types::Standard and Types::ReadOnly modules - which I now believe you wrote (?) so i hope you dont mind me bugging you with a related question!
Suppose I have a module with the code you suggested:
my $colour_hash = Locked[ Dict[ red => Optional[Int], blue => Optional[Int], green => Optional[Int], ], ]; has scores => ( is => 'rw', isa => $colour_hash, default => sub{ {} }, coerce => 1, );
but now I have another package which inherits from this one. Is there any simple way to extend the list of allowed keys in the inherited class?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: constraining the keys of a HashRef in Moose
by tobyink (Canon) on Sep 03, 2013 at 08:09 UTC | |
by tomgracey (Scribe) on Sep 04, 2013 at 11:13 UTC |