more useful options | |
PerlMonks |
Moose from ArrayRef[HashRef] to ArrayRef[Object]by saintex (Scribe) |
on Feb 23, 2011 at 14:52 UTC ( [id://889800]=perlquestion: print w/replies, xml ) | Need Help?? |
saintex has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
Following a previous conversation (for which I thank all the Monks): href="http://www.perlmonks.org/?node_id=887227 I have started to use MooseX::SimpleConfig to have object constructions from config files. But I have a problem related to types: I would like to have an ArrayRef of objects, but I forced to have an ArrayRef of hashes. How I can force a type to be another one? Here there is some code, just to have an idea. I inserted only the essential parts. YAML FILE:
Page Class:
Objects container class (with ArrayRef):
And finally on main script, the object construction: But, while page is an ArrayRef[Page] I have this error:
If I choose an ArrayRef[HashRef], all works fine. The problem is that I need exaclty an ArrayRef[Page]. So I could coerce one type in another. I readed something about coercion in Moose, but I don't understand how to use it in my case. Any suggestions is welcome. Thank you!
Back to
Seekers of Perl Wisdom
|
|