Last active
December 22, 2015 09:19
-
-
Save Timshel/6451272 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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