Created
April 5, 2011 16:13
-
-
Save lucascs/903913 to your computer and use it in GitHub Desktop.
Scala Active Record with DI
This file contains 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
@Component | |
class ActiveRecord[T](session:Session) { | |
implicit def obj2AR(obj:T) = new AR(session, obj) | |
} | |
class AR[T](session:Session, obj:T) { | |
def save = session.save(obj) | |
} |
This file contains 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
@Resource | |
class ProductController(ar:ActiveRecord[Product]) { | |
import ar._ | |
def save(product:Product) { | |
product.save | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment