Skip to content

Instantly share code, notes, and snippets.

@Timshel
Last active December 22, 2015 09:19
Show Gist options
  • Save Timshel/6451272 to your computer and use it in GitHub Desktop.
Save Timshel/6451272 to your computer and use it in GitHub Desktop.
object Binder{
implicit def navigationPathBindable(implicit longBinder: PathBindable[Long]) = new PathBindable[Navigation] {
def bind(key: String, value: String): Either[String, Navigation] = {
for{
id <- longBinder.bind(key, value).right
nav <- Navigation.getNavigation(id).toRight("Navigation not found").right
} yield nav
}
def unbind(key: String, nav: Navigation): String = {
longBinder.unbind(key, nav.id)
}
}
}
object Binder{
trait EnumBinder[A,B](implicit binder: PathBindable[B]) = new PathBindable[A] {
def bind(key: String, value: String): Either[String, A] = {
for{
id <- binder.bind(key, value).right
nav <- // TODO
} yield nav
}
def unbind(key: String, nav: A): String = {
longBinder.unbind(key, binder.unbind( //TODO ))
}
}
implicit object totoBinder extends EnumBinder[Toto, Long]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment