Created
August 7, 2012 14:35
-
-
Save rktoomey/3285885 to your computer and use it in GitHub Desktop.
Suppress default args
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
scala> import model._ | |
import model._ | |
scala> import model.suppress_default_args._ | |
import model.suppress_default_args._ | |
scala> import com.novus.salat._ | |
import com.novus.salat._ | |
scala> import com.mongodb.casbah.Imports._ | |
import com.mongodb.casbah.Imports._ | |
scala> ctx.name | |
res0: String = suppress_default_args | |
scala> val b = Bar() | |
b: model.Bar = Bar(50212773e4b04022d3e7dffb,Map()) | |
scala> val dbo = grater[Bar].asDBObject(b) | |
dbo: com.mongodb.casbah.Imports.DBObject = { "_id" : { "$oid" : "50212773e4b04022d3e7dffb"}} | |
scala> val b_* = grater[Bar].asObject(dbo) | |
b_*: model.Bar = Bar(50212773e4b04022d3e7dffb,Map()) | |
scala> b == b_* | |
res2: Boolean = true |
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
package model | |
import org.bson.types.ObjectId | |
import com.novus.salat.Context | |
case class Bar(_id: ObjectId = new ObjectId, baz: Map[String, String] = Map.empty) | |
package object suppress_default_args { | |
implicit val ctx = new Context { | |
val name = "suppress_default_args" | |
override val suppressDefaultArgs = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment