Skip to content
Snippets Groups Projects
Commit 1500e4f3 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Fix bug on freevar

parent 913d16ec
No related branches found
No related tags found
No related merge requests found
......@@ -21,9 +21,9 @@ import nl.lumc.sasc.biopet.utils.ConfigUtils.ImplicitConversions
trait Configurable extends ImplicitConversions {
val root: Configurable
def configPath: List[String] = if (root != null) root.configFullPath else List()
protected lazy val configName = getClass.getSimpleName.toLowerCase
protected lazy val configFullPath = configName :: configPath
lazy val configPath: List[String] = if (root != null) root.configFullPath else List()
protected[config] lazy val configName = getClass.getSimpleName.toLowerCase
protected[config] lazy val configFullPath: List[String] = configPath ::: configName :: Nil
var defaults: scala.collection.mutable.Map[String, Any] = if (root != null) scala.collection.mutable.Map(root.defaults.toArray: _*)
else scala.collection.mutable.Map()
......@@ -32,7 +32,7 @@ trait Configurable extends ImplicitConversions {
protected class ConfigFunctions {
def apply(key: String, default: Any = null, submodule: String = null, required: Boolean = false, freeVar: Boolean = true): ConfigValue = {
val m = if (submodule != null) submodule else configName
val p = (if (submodule != null) configName :: configPath else configPath).reverse
val p = (if (submodule != null) configName :: configPath else configPath)
val d = {
val value = Config.getValueFromMap(defaults.toMap, ConfigValueIndex(m, p, key, freeVar))
if (value.isDefined) value.get.value else default
......@@ -43,13 +43,13 @@ trait Configurable extends ImplicitConversions {
throw new IllegalStateException("Value in config could not be found but it is required, key: " + key + " module: " + m + " path: " + p)
} else return null
}
if (d == null) return Config.global(m, p, key, freeVar)
if (d == null) return Config.global(m, p, key, freeVar = freeVar)
else return Config.global(m, p, key, d, freeVar)
}
def contains(key: String, submodule: String = null, freeVar: Boolean = true) = {
val m = if (submodule != null) submodule else configName
val p = (if (submodule != null) configName :: configPath else configPath).reverse
val p = (if (submodule != null) configName :: configPath else configPath)
Config.global.contains(m, p, key, freeVar) || !(Config.getValueFromMap(defaults.toMap, ConfigValueIndex(m, p, key, freeVar)) == None)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment