Last active
March 8, 2016 20:33
-
-
Save jonvuri/08e8cf8f83888d5c75e6 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
case class Context(local: Boolean) | |
trait FileSource { | |
def readFile(location: String): String | |
def writeFile(location: String, content: String): Unit | |
} | |
object FileSource { | |
def apply(context: Context): FileSource { | |
if (context.local) new LocalFileSource(context) else new ExternalFileSource(context) | |
} | |
} | |
class LocalFileSource(context: Context) extends FileSource { | |
// implementation | |
} | |
class ExternalFileSource(context: Context) extends FileSource { | |
// implementation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment