Fix AspectConfig::get_for() implementation

This commit is contained in:
Matthias Beyer 2016-07-16 00:08:58 +02:00
parent 5a4e6b4af6
commit c8edb2102f

View file

@ -200,6 +200,7 @@ pub struct AspectConfig {
impl AspectConfig {
pub fn new(init: Value) -> AspectConfig {
debug!("Trying to parse AspectConfig from: {:?}", init);
let parallel = AspectConfig::is_parallel(&init);
let muthooks = AspectConfig::allows_mutable_hooks(&init);
AspectConfig {
@ -247,11 +248,21 @@ impl AspectConfig {
///
/// Returns `None` if one of the keys in the chain is not available
pub fn get_for(v: &Option<Value>, a_name: String) -> Option<AspectConfig> {
match *v {
Some(Value::Table(ref tabl)) => tabl.get(&a_name[..])
.map(|asp| AspectConfig::new(asp.clone())),
debug!("Get aspect configuration for {:?} from {:?}", a_name, v);
let res = match *v {
Some(Value::Table(ref tabl)) => {
match tabl.get("aspects") {
Some(&Value::Table(ref tabl)) => {
tabl.get(&a_name[..]).map(|asp| AspectConfig::new(asp.clone()))
},
_ => None,
}
},
_ => None,
}
};
debug!("Found aspect configuration for {:?}: {:?}", a_name, res);
res
}
}