Created
May 17, 2013 20:39
-
-
Save OlegIlyenko/5601831 to your computer and use it in GitHub Desktop.
Fixed version of SecureModule
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
| import scaldi.{Injector, Module, Injectable} | |
| trait Security { | |
| type User | |
| def authenticate(username: String, password: String): Boolean | |
| } | |
| class SecuritySample extends Security { | |
| def authenticate(username: String, password: String): Boolean = false | |
| } | |
| class SecurityImpl extends Security { | |
| def authenticate(username: String, password: String): Boolean = { | |
| User.authenticate(username, password) match { | |
| case Some(user: User) => true | |
| case _ => false | |
| } | |
| } | |
| } | |
| class ModSec(implicit inj: Injector) extends Injectable { | |
| def secure = inject [Security] (identified by 'secure and by default new SecuritySample) | |
| } | |
| object ConfigModule extends Module { | |
| bind [Security] as 'secure to new SecurityImpl | |
| bind [ModSec] to new ModSec | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment