Permalink
Browse files

More idiomatic

  • Loading branch information...
1 parent 1a9e75e commit 5d4e152022ad0b087a10e64dc30f7b2b68fe0541 @jroper jroper committed May 21, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 src/main/scala/play/modules/mongodb/jackson/MongoDB.scala
@@ -179,10 +179,8 @@ class MongoDBPlugin(val app: Application) extends Plugin {
_.configure(defaultMapper)
} getOrElse defaultMapper
- val defaultWriteConcern = app.configuration.getString("mongodb.defaultWriteConcern") map { value =>
- WriteConcern.valueOf(value)
- } filter {
- _ != null
+ val defaultWriteConcern = app.configuration.getString("mongodb.defaultWriteConcern") flatMap { value =>
+ Option(WriteConcern.valueOf(value))
}
app.configuration.getString("mongodb.uri") match {
@@ -235,8 +233,8 @@ class MongoDBPlugin(val app: Application) extends Plugin {
// Authenticate if necessary
val credentials = app.configuration.getString("mongodb.credentials")
- if (credentials.isDefined) {
- credentials.get.split(":", 2) match {
+ credentials.foreach {
+ _.split(":", 2) match {
case Array(username: String, password: String) => {
if (!db.authenticate(username, password.toCharArray)) {
throw new IllegalArgumentException("MongoDB authentication failed for user: " + username + " on database: "

0 comments on commit 5d4e152

Please sign in to comment.