Add configuration parsing/getter for denying of mutable hooks

This commit is contained in:
Matthias Beyer 2016-07-06 19:10:17 +02:00
parent b4b719b753
commit 7f14639c1e
1 changed files with 21 additions and 0 deletions

View File

@ -193,6 +193,7 @@ pub fn get_post_move_aspect_names(value: &Option<Value>) -> Vec<String> {
#[derive(Debug)] #[derive(Debug)]
pub struct AspectConfig { pub struct AspectConfig {
parallel: bool, parallel: bool,
mutable_hooks: bool,
config: Value, config: Value,
} }
@ -200,8 +201,10 @@ impl AspectConfig {
pub fn new(init: Value) -> AspectConfig { pub fn new(init: Value) -> AspectConfig {
let parallel = AspectConfig::is_parallel(&init); let parallel = AspectConfig::is_parallel(&init);
let muthooks = AspectConfig::allows_mutable_hooks(&init);
AspectConfig { AspectConfig {
config: init, config: init,
mutable_hooks: muthooks,
parallel: parallel, parallel: parallel,
} }
} }
@ -220,6 +223,24 @@ impl AspectConfig {
} }
} }
fn allows_mutable_hooks(init: &Value) -> bool {
match *init {
Value::Table(ref t) =>
t.get("mutable_hooks")
.map_or(false, |value| {
match *value {
Value::Boolean(b) => b,
_ => false,
}
}),
_ => false,
}
}
pub fn allow_mutable_hooks(&self) -> bool {
self.mutable_hooks
}
/// Get the aspect configuration for an aspect. /// Get the aspect configuration for an aspect.
/// ///
/// Pass the store configuration object, this searches in `[aspects][<aspect_name>]`. /// Pass the store configuration object, this searches in `[aspects][<aspect_name>]`.