Created
March 11, 2012 11:47
-
-
Save andypetrella/2016161 to your computer and use it in GitHub Desktop.
Salat and Play 2.0
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
//... | |
val novusSnapsRepo = "Novus Snapshots Repository" at "http://repo.novus.com/snapshots/" | |
val salatCore = "com.novus" %% "salat-core" % "0.0.8-SNAPSHOT" withSources | |
val salatUtil = "com.novus" %% "salat-util" % "0.0.8-SNAPSHOT" withSources | |
val appDependencies = Seq( | |
// Add your project dependencies here, | |
salatCore, | |
salatUtil | |
) | |
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings( | |
// Add your own project settings here | |
resolvers ++= Seq( | |
novusSnapsRepo | |
) | |
) | |
//... |
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
case class Model(_id:ObjectId, data: String = "") { | |
} | |
object Model { | |
// Defining this, ease the usage of the grater, otherwise it implies the user to import himself all Salat deps. Now, we can simply use this val without extra imports. | |
def graterModel(implicit ctx:Context): Grater[Model] = grater[Model] | |
def to(m:Model):DBObject= graterModel.asDBObject(m) | |
def from(m:DBObject):Model = graterModel.asObject(m) | |
} |
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 object salatctx { | |
/** | |
* Here is where we define the custom Play serialization context, including the Play classloader. | |
*/ | |
implicit val ctx = { | |
val c = new Context { | |
val name = "play-context" | |
} | |
c.registerClassLoader(Play.classloader) | |
c | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment