diff options
author | Daniil Baturin <daniil@baturin.org> | 2015-09-23 08:09:54 +0600 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-09-23 08:09:54 +0600 |
commit | 39ca40199cd10d3bebfa7cb7f68b4be23ccfd7d7 (patch) | |
tree | 0db0c21da535aacaa82cbf5f99cb1e5c1c628b29 /src | |
parent | 1871fb60c8f9f9076be4ce053ccb4a886dd53627 (diff) | |
download | vyconf-39ca40199cd10d3bebfa7cb7f68b4be23ccfd7d7.tar.gz vyconf-39ca40199cd10d3bebfa7cb7f68b4be23ccfd7d7.zip |
Add delete function to session.
Diffstat (limited to 'src')
-rw-r--r-- | src/session.ml | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/session.ml b/src/session.ml index b59b473..ff1cce7 100644 --- a/src/session.ml +++ b/src/session.ml @@ -38,3 +38,16 @@ let rec apply_changes changeset config = match changeset with | [] -> config | c :: cs -> apply_changes cs (apply_cfg_op c config) + +let set w s path = + let path, value = RT.validate_path w.validators w.reference_tree path in + let value_behaviour = if RT.is_multi w.reference_tree path then CT.AddValue else CT.ReplaceValue in + let op = CfgSet (path, value, value_behaviour) in + let config = apply_cfg_op op s.proposed_config in + {s with proposed_config=config; changeset=(op :: s.changeset)} + +let delete w s path = + let path, value = RT.validate_path w.validators w.reference_tree path in + let op = CfgDelete (path, value) in + let config = apply_cfg_op op s.proposed_config in + {s with proposed_config=config; changeset=(op :: s.changeset)} |