Created
October 17, 2012 22:26
-
-
Save djspiewak/3908729 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
trait ConfigComponent { | |
type Config | |
def config: Config | |
} | |
trait MySQLStorageComponent extends StorageComponent with ConfigComponent { | |
type Config <: MySQLConfig | |
override def storeUser(user: User) { ... } | |
override def retrieveUser(id: Int): Option[User] = ... | |
case class User(id: Int, hash:Vector[Byte]) extends UserLike | |
trait MySQLConfig { | |
def mysqlHost: String | |
def mysqlPort: Int | |
} | |
} | |
trait GravatarComponent extends StorageComponent { | |
type Config <: GravatarConfig | |
def avatarURL(user: User): String = { ... } | |
trait GravatarConfig { | |
def token: String | |
} | |
} | |
class RESTService extends MySQLStorageComponent with GravatarComponent with ... { | |
type Config = config.type | |
override object config extends MySQLConfig with GravatarConfig { | |
val mysqlHost = "localhost | |
val mysqlPort = 3336 | |
val token = "1234cafebabe" | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment