Skip to content

Instantly share code, notes, and snippets.

@ryantanner
Created January 27, 2013 18:40
Show Gist options
  • Save ryantanner/4649683 to your computer and use it in GitHub Desktop.
Save ryantanner/4649683 to your computer and use it in GitHub Desktop.
object Account
object Clob {
def unapply(clob: Clob): Option[String] = Some(clob.getSubString(1, clob.length.toInt))
}
implicit val rowToPermission: Column[Permission] = {
Column.nonNull[Permission] { (value, meta) =>
value match {
case Clob("Administrator") => Right(Administrator)
case Clob("NormalUser") => Right(NormalUser)
case _ => Left(TypeDoesNotMatch(
"Cannot convert %s : %s to Permission for column %s".format(value, value.getClass, meta.column)))
}
}
}
val simple = {
get[String]("account.id") ~
get[String]("account.email") ~
get[String]("account.password") ~
get[String]("account.name") ~
get[Permission]("account.permission") map {
case id~email~pass~name~perm => Account(id, email, pass, name, perm)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment