Skip to content

Instantly share code, notes, and snippets.

View HarryHuang's full-sized avatar

Harry Huang HarryHuang

View GitHub Profile
@HarryHuang
HarryHuang / cake_pattern_di.scala
Created November 19, 2011 11:54
Scala Dependency Injection: an improved cake pattern
//harry huang [[email protected]]
//
//After reading the original post [http://jboner.github.com/2008/10/06/real-world-scala-dependency-injection-di.html, ]
//the original cake pattern seems quite verbose for me, and it is quite invasive, so I spent a bit time
//and come up with an improved version of cake pattern, which I call it "Auto Cake DI". It is working
//well with any POST(plain old scala trait)/POSO(plain old scala object) which means that anything can be
//injected without modification or introducing new traits.
/*---------inject trait---------*/
trait Inject[+T] { def inject: T }