Created
July 29, 2013 03:26
-
-
Save gakuzzzz/6101977 to your computer and use it in GitHub Desktop.
cake と cake じゃない所と
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
package disample | |
case class DiSampleConfig(foo: Int, bar: String) | |
object DiSampleConfig { | |
implicit val configs: Configs[DiSampleConfig] = Configs { c => | |
DiSampleConfig( | |
foo = c.get[Int]("foo"), | |
bar = c.get[String]("bar") | |
) | |
} | |
} | |
trait DiSampleComponents { | |
lazy val disampleConfig: DiSampleConfig = | |
ConfigFactory.load("applocation.conf").get[DiSampleConfig]("disample") | |
} |
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
package disample.hoge | |
class HogeDao { | |
} | |
class HogeService(hogeDao: HogeDao, config: DiSampleConfig) { | |
} | |
trait HogeComponents { | |
self: DiSampleComponents => | |
lazy val hogeDao: HogeDao = new HogeDao() | |
lazy val hogeService: HogeService = new HogeService(hogeDao, disampleConfig) | |
} |
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
package disample.piyo | |
class PiyoDao { | |
} | |
class PiyoService(piyoDao: PiyoDao, config: DiSampleConfig) { | |
} | |
trait PiyoComponents { | |
self: DiSampleComponents => | |
lazy val piyoDao: PiyoDao = new PiyoDao() | |
lazy val piyoService: PiyoService = new PiyoService(piyoDao, disampleConfig) | |
} |
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
trait ComponentRepository extends HogeComponents with PiyoComponents with DiSampleComponents | |
trait AAAController extends ComponentRepository { | |
def action = Action { | |
hogeService.XXX | |
} | |
} |
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
class AAAControllerSpec with mockit { | |
object AAAController extends AAAController { | |
override lazy val hogeDao: HogeDao = mock[HogeDao] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment