Skip to content

Instantly share code, notes, and snippets.

@gvolpe
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gvolpe/9751b9abd5aa11770e07 to your computer and use it in GitHub Desktop.
Save gvolpe/9751b9abd5aa11770e07 to your computer and use it in GitHub Desktop.
ES_Scala_Refactor
object TheApp extends App {
EventProcessor("BR").process
}
trait ESClient {
def country: String
def settings: String = "settings-" + country
def client: String
}
trait ESTransportClient extends ESClient {
val client = "transport-" + settings
}
trait ESNodeClient extends ESClient {
val client = "node-" + settings
}
class EventProcessor {
self: ESClient =>
def process: Unit = {
println(client)
}
}
// companion object
object EventProcessor {
def apply(theCountry: String): EventProcessor = {
new EventProcessor with ESTransportClient {
override def country = theCountry
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment