Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
- Fun and games to enable additivity in fluid syntax.
Browse files Browse the repository at this point in the history
- Added posterous plugin
  • Loading branch information
Brendan W. McAdams committed Jul 18, 2010
1 parent 4966ad7 commit 91b33ac
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions project/plugins/Plugin.scala
@@ -1,6 +1,8 @@
class Plugins(info: sbt.ProjectInfo) extends sbt.PluginDefinition(info) {
val codaRepo = "Coda Hale's Repository" at "http://repo.codahale.com/"
val rsyncSBT = "com.codahale" % "rsync-sbt" % "0.1.0"
val posterousRepo = "t_repo" at "http://tristanhunt.com:8081/content/groups/public/"
val posterous = "net.databinder" % "posterous-sbt" % "0.1.4"
}

// vim: set ts=2 sw=2 sts=2 et:
15 changes: 13 additions & 2 deletions src/main/scala/mongodb/Implicits.scala
Expand Up @@ -172,7 +172,11 @@ trait Implicits extends FluidQueryBarewordOps {
*/
implicit def mongoNestedQueryStatements(nested: Tuple2[String, DBObject]) = new {
val field = nested._1
} with FluidQueryOperators { dbObj = Some(nested._2) }
} with FluidQueryOperators {
dbObj = Some(nested._2)
/* def ++[A <% DBObject](right: A): DBObject = wrapDBObj(nested) ++ wrapDBObj(right)
*/ }


/*[>* For several of the items which are geared towards nested operations like $set/$unset,
* We tack other operators onto them for sanity.
Expand Down Expand Up @@ -220,18 +224,25 @@ trait Implicits extends FluidQueryBarewordOps {
/*
* Implicit extension methods to convert Products to Mongo DBObject instances.
*/
implicit def productAsDBObject(p: Product) = new {
implicit def productPimp(p: Product) = new {
/*
* Return a Mongo <code>DBObject</code> containing the Map values
* @return DBObject
*/
def asDBObject = productToMongoDBObject(p)
def ++[A <% DBObject : Manifest](right: A): DBObject = asDBObject ++ wrapDBObj(right)
}

// This may cause misbehavor ... aka "HERE BE DRAGONS"
implicit def tuplePairToDBObject(pair: (String, DBObject)): DBObject =
pair.asDBObject

// A few hacks for defining straight off conversions
implicit def tuplePairUtils(pair: (String, Any)) = new {
def ++[A <% DBObject : Manifest](right: A): DBObject = pair.asDBObject ++ wrapDBObj(right)
def ++(right: (String, Any)): DBObject = pair.asDBObject ++ right.asDBObject
}

implicit def wrapDBFile(in: com.mongodb.gridfs.GridFSDBFile) = new GridFSDBFile(in)
implicit def wrapInFile(in: com.mongodb.gridfs.GridFSInputFile) = new GridFSInputFile(in)

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/mongodb/MongoCollection.scala
Expand Up @@ -289,7 +289,7 @@ trait MongoCollectionWrapper extends Logging {
*
* @param x object to save to the collection
*/
def +=[A <% DBObject](x: A) = save(x)
def +=[A <% DBObject : Manifest](x: A) = save(x)

/**
* MongoDB DBCollection.remove method
Expand All @@ -298,7 +298,7 @@ trait MongoCollectionWrapper extends Logging {
*
* @param x object to remove from the collection
*/
def -=[A <% DBObject](x: A) = remove(x)
def -=[A <% DBObject : Manifest](x: A) = remove(x)

/**
* Helper method for anyone who returns an Option
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/mongodb/MongoDBObject.scala
Expand Up @@ -82,7 +82,8 @@ trait MongoDBObject extends Map[String, Object] with Logging {
underlying.removeField(key)
this
}

/*override def ++[A <% DBObject](right: A): DBObject = asDBObject ++ wrapDBObj(right)
*/

/* Methods needed in order to be a proper DBObject */
def containsField(s: String) = underlying.containsField(s)
Expand Down

0 comments on commit 91b33ac

Please sign in to comment.