Eval evaluates expr against a map that contains the field values.
(expr Expr, m map[string]interface{}, useFuncValuer bool)
| 32 | |
| 33 | // Eval evaluates expr against a map that contains the field values. |
| 34 | func Eval(expr Expr, m map[string]interface{}, useFuncValuer bool) bool { |
| 35 | var eval ValuerEval |
| 36 | if useFuncValuer { |
| 37 | eval = ValuerEval{Valuer: MultiValuer(MapValuer(m), FunctionValuer{m})} |
| 38 | } else { |
| 39 | eval = ValuerEval{Valuer: MapValuer(m)} |
| 40 | } |
| 41 | v, ok := eval.Eval(expr).(bool) |
| 42 | if !ok { |
| 43 | return false |
| 44 | } |
| 45 | return v |
| 46 | } |
| 47 | |
| 48 | // MapValuer is a valuer that substitutes values for the mapped interface. |
| 49 | type MapValuer map[string]interface{} |
no test coverage detected