AddQualifier creates a wrapper over the incoming qualifier which observes the qualification result.
(q Qualifier)
| 1078 | // AddQualifier creates a wrapper over the incoming qualifier which observes the qualification |
| 1079 | // result. |
| 1080 | func (e *evalWatchAttr) AddQualifier(q Qualifier) (Attribute, error) { |
| 1081 | switch qual := q.(type) { |
| 1082 | // By default, the qualifier is either a constant or an attribute |
| 1083 | // There may be some custom cases where the attribute is neither. |
| 1084 | case ConstantQualifier: |
| 1085 | // Expose a method to test whether the qualifier matches the input pattern. |
| 1086 | q = &evalWatchConstQual{ |
| 1087 | ConstantQualifier: qual, |
| 1088 | observer: e.observer, |
| 1089 | adapter: e.Adapter(), |
| 1090 | } |
| 1091 | case *evalWatchAttr: |
| 1092 | // Unwrap the evalWatchAttr since the observation will be applied during Qualify or |
| 1093 | // QualifyIfPresent rather than Eval. |
| 1094 | q = &evalWatchAttrQual{ |
| 1095 | Attribute: qual.InterpretableAttribute, |
| 1096 | observer: e.observer, |
| 1097 | adapter: e.Adapter(), |
| 1098 | } |
| 1099 | case Attribute: |
| 1100 | // Expose methods which intercept the qualification prior to being applied as a qualifier. |
| 1101 | // Using this interface ensures that the qualifier is converted to a constant value one |
| 1102 | // time during attribute pattern matching as the method embeds the Attribute interface |
| 1103 | // needed to trip the conversion to a constant. |
| 1104 | q = &evalWatchAttrQual{ |
| 1105 | Attribute: qual, |
| 1106 | observer: e.observer, |
| 1107 | adapter: e.Adapter(), |
| 1108 | } |
| 1109 | default: |
| 1110 | // This is likely a custom qualifier type. |
| 1111 | q = &evalWatchQual{ |
| 1112 | Qualifier: qual, |
| 1113 | observer: e.observer, |
| 1114 | adapter: e.Adapter(), |
| 1115 | } |
| 1116 | } |
| 1117 | _, err := e.InterpretableAttribute.AddQualifier(q) |
| 1118 | return e, err |
| 1119 | } |
| 1120 | |
| 1121 | // Exec implements the InterpretableV2 interface method. |
| 1122 | func (e *evalWatchAttr) Exec(frame *ExecutionFrame) ref.Val { |
nothing calls this directly
no test coverage detected