Skip to content

Instantly share code, notes, and snippets.

@havocp
Created May 10, 2012 02:26
Show Gist options
  • Save havocp/2650592 to your computer and use it in GitHub Desktop.
Save havocp/2650592 to your computer and use it in GitHub Desktop.
Binding implicits
trait CacheContext
trait Cache {
def lookup(query: String)(implicit context: CacheContext): String
def store(id: String, value: String)(implicit context: CacheContext): Unit
}
class BoundCache(private val delegate: Cache)(implicit private val context: CacheContext) {
def lookup(query: String): String =
delegate.lookup(query)
def store(id: String, value: String): Unit =
delegate.store(id, value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment