MCPcopy Create free account
hub / github.com/cel-expr/cel-go / AddQualifier

Method AddQualifier

interpreter/interpretable.go:1038–1077  ·  view source on GitHub ↗

AddQualifier creates a wrapper over the incoming qualifier which observes the qualification result.

(q Qualifier)

Source from the content-addressed store, hash-verified

1036// AddQualifier creates a wrapper over the incoming qualifier which observes the qualification
1037// result.
1038func (e *evalWatchAttr) AddQualifier(q Qualifier) (Attribute, error) {
1039 switch qual := q.(type) {
1040 // By default, the qualifier is either a constant or an attribute
1041 // There may be some custom cases where the attribute is neither.
1042 case ConstantQualifier:
1043 // Expose a method to test whether the qualifier matches the input pattern.
1044 q = &evalWatchConstQual{
1045 ConstantQualifier: qual,
1046 observer: e.observer,
1047 adapter: e.Adapter(),
1048 }
1049 case *evalWatchAttr:
1050 // Unwrap the evalWatchAttr since the observation will be applied during Qualify or
1051 // QualifyIfPresent rather than Eval.
1052 q = &evalWatchAttrQual{
1053 Attribute: qual.InterpretableAttribute,
1054 observer: e.observer,
1055 adapter: e.Adapter(),
1056 }
1057 case Attribute:
1058 // Expose methods which intercept the qualification prior to being applied as a qualifier.
1059 // Using this interface ensures that the qualifier is converted to a constant value one
1060 // time during attribute pattern matching as the method embeds the Attribute interface
1061 // needed to trip the conversion to a constant.
1062 q = &evalWatchAttrQual{
1063 Attribute: qual,
1064 observer: e.observer,
1065 adapter: e.Adapter(),
1066 }
1067 default:
1068 // This is likely a custom qualifier type.
1069 q = &evalWatchQual{
1070 Qualifier: qual,
1071 observer: e.observer,
1072 adapter: e.Adapter(),
1073 }
1074 }
1075 _, err := e.InterpretableAttribute.AddQualifier(q)
1076 return e, err
1077}
1078
1079// Exec implements the InterpretableV2 interface method.
1080func (e *evalWatchAttr) Exec(frame *ExecutionFrame) ref.Val {

Callers

nothing calls this directly

Calls 2

AdapterMethod · 0.65
AddQualifierMethod · 0.65

Tested by

no test coverage detected