net.ceedubs.ficus.readers.OptionReader.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ficus_2.10 Show documentation
Show all versions of ficus_2.10 Show documentation
A Scala-friendly wrapper companion for Typesafe config
The newest version!
package net.ceedubs.ficus.readers
import com.typesafe.config.Config
trait OptionReader {
implicit def optionValueReader[A](implicit valueReader: ValueReader[A]): ValueReader[Option[A]] = new ValueReader[Option[A]] {
def read(config: Config, path: String): Option[A] = {
if (config.hasPath(path)) {
Some(valueReader.read(config, path))
} else {
None
}
}
}
}
object OptionReader extends OptionReader