diff --git a/helper.go b/helper.go index 15c8309..2301dc6 100644 --- a/helper.go +++ b/helper.go @@ -100,6 +100,19 @@ func newEmptyOptions(eval *evalVisitor) *Options { // Context Values // +// ValueFromAllCtx returns the first occurence of field value from all the contexts in the stack. The search occurs backwards from the current context, ending at the root context. +func (options *Options) ValueFromAllCtx(name string) interface{} { + // Loop through all contexts in the stack + for index := range options.eval.ctx { + value := options.eval.evalField(options.eval.ancestorCtx(index), name, false) + if value.IsValid() { + return value.Interface() + } + } + + return nil +} + // Value returns field value from current context. func (options *Options) Value(name string) interface{} { value := options.eval.evalField(options.eval.curCtx(), name, false)