package test

import play.api.libs.json.Json
import controllers.XmlSerializable

case class Person(firstName: String, surName: String, age: Int) extends XmlSerializable{
  //The XML serialization is (for good and bad) defined explicitly
  override def toXML =
    <person>
      <firstName>{firstName}</firstName>
      <surName>{surName}</surName>
      <age>{age}</age>
    </person>
}
object Person {
  // We define the Json Writes in the companion object,
  // so it will be automatically inferred whenever we want to write this class
  implicit val personWrites = Json.writes[Person]
}


// Pretend this is for real...
object PersonRepository {
  def get(id: Int) = Person("Erik", "Fried", 34)
}