Created
April 8, 2018 03:03
-
-
Save brianhsu/2b791f6ff59f89b25f7e131d49106c32 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
object InMemoryUser { | |
def makeInMemoryUser: UserRepo = { | |
val inMemory = new InMemoryUserReadable with InMemoryUserWritable | |
UserRepo(inMemory, inMemory) | |
} | |
trait InMemoryUserBase { | |
protected var userList: List[User] = Nil | |
} | |
trait InMemoryUserReadable extends InMemoryUserBase with UserReadable { | |
override def find(email: String): Option[User] = userList.find(_.email == email) | |
} | |
trait InMemoryUserWritable extends InMemoryUserBase with UserWritable { | |
override def insert(user: User): Unit = { | |
userList ::= user | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment