I've been having a look at the computer-database sample and I noticed that in order to reuse the Computer parser, the list method uses the Computer.withCompany parser, which returns a tuple of (Computer, Company)
In the case I have to handle, instead of a reference to the id of the computer I want to have a Computer object, like this
case class Computer(id: Pk[Long] = NotAssigned, name: String, introduced: Option[Date], discontinued: Option[Date], company: Company)
so I was thinking how can I achieve something like the following (it's seudocode, of course)
val simple = {
get[Pk[Long]]("computer.id") ~
get[String]("computer.name") ~
get[Option[Date]]("computer.introduced") ~
get[Option[Date]]("computer.discontinued") ~
get[Company]("company.*") map {
case id~name~introduced~discontinued~company => Computer(id, name, introduced, discontinued, company)
}
}
Obviously, the tricky part would be how to solve getCompany
any idea???