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