Created
February 9, 2015 03:06
-
-
Save tkawachi/1d26ad7ef840bc966949 to your computer and use it in GitHub Desktop.
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
import com.github.kxbmap.configs._ | |
import com.typesafe.config.Config | |
object ConfigAny { | |
implicit class ConfigAnyImplicit(val config: Config) { | |
def optAny[A: AtPath](keys: Seq[String])(implicit cc: CatchCond = CatchCond.missing): Option[A] = | |
keys.foldLeft(None: Option[A]) { (a, e) => a.orElse(config.opt[A](e)) } | |
def getAny[A: AtPath](keys: Seq[String])(implicit cc: CatchCond = CatchCond.missing): A = | |
optAny(keys).getOrElse(sys.error(s"Any of $keys are not specified.")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment