Last active
August 29, 2015 14:16
-
-
Save gvolpe/9751b9abd5aa11770e07 to your computer and use it in GitHub Desktop.
ES_Scala_Refactor
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 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