Add configuration parsing/getter for denying of mutable hooks
This commit is contained in:
parent
b4b719b753
commit
7f14639c1e
1 changed files with 21 additions and 0 deletions
|
@ -193,6 +193,7 @@ pub fn get_post_move_aspect_names(value: &Option<Value>) -> Vec<String> {
|
|||
#[derive(Debug)]
|
||||
pub struct AspectConfig {
|
||||
parallel: bool,
|
||||
mutable_hooks: bool,
|
||||
config: Value,
|
||||
}
|
||||
|
||||
|
@ -200,8 +201,10 @@ impl AspectConfig {
|
|||
|
||||
pub fn new(init: Value) -> AspectConfig {
|
||||
let parallel = AspectConfig::is_parallel(&init);
|
||||
let muthooks = AspectConfig::allows_mutable_hooks(&init);
|
||||
AspectConfig {
|
||||
config: init,
|
||||
mutable_hooks: muthooks,
|
||||
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.
|
||||
///
|
||||
/// Pass the store configuration object, this searches in `[aspects][<aspect_name>]`.
|
||||
|
|
Loading…
Reference in a new issue