Exemple #1
0
func unsetFor(t *algebra.UnsetTerm, clone value.AnnotatedValue, context *Context) error {
	arrays, e := arraysFor(t.UpdateFor(), clone, context)
	if e != nil {
		return e
	}

	cvals, e := buildFor(t.UpdateFor(), clone, arrays, context)
	if e != nil {
		return e
	}

	when := t.UpdateFor().When()
	for i := 0; i < len(cvals); i++ {
		if when != nil {
			w, e := when.Evaluate(cvals[i], context)
			if e != nil {
				return e
			}

			if !w.Truth() {
				continue
			}
		}

		t.Path().Unset(cvals[i], context)
	}

	return nil
}
Exemple #2
0
func unsetPath(t *algebra.UnsetTerm, clone value.AnnotatedValue, context *Context) error {
	if t.UpdateFor() != nil {
		return unsetFor(t, clone, context)
	}

	t.Path().Unset(clone, context)
	return nil
}