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

Method AddQualifier

interpreter/interpretable.go:1492–1531  ·  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

1490// AddQualifier creates a wrapper over the incoming qualifier which observes the qualification
1491// result.
1492func (e *evalWatchAttr) AddQualifier(q Qualifier) (Attribute, error) {
1493 switch qual := q.(type) {
1494 // By default, the qualifier is either a constant or an attribute
1495 // There may be some custom cases where the attribute is neither.
1496 case ConstantQualifier:
1497 // Expose a method to test whether the qualifier matches the input pattern.
1498 q = &evalWatchConstQual{
1499 ConstantQualifier: qual,
1500 observer: e.observer,
1501 adapter: e.Adapter(),
1502 }
1503 case *evalWatchAttr:
1504 // Unwrap the evalWatchAttr since the observation will be applied during Qualify or
1505 // QualifyIfPresent rather than Eval.
1506 q = &evalWatchAttrQual{
1507 Attribute: qual.InterpretableAttribute,
1508 observer: e.observer,
1509 adapter: e.Adapter(),
1510 }
1511 case Attribute:
1512 // Expose methods which intercept the qualification prior to being applied as a qualifier.
1513 // Using this interface ensures that the qualifier is converted to a constant value one
1514 // time during attribute pattern matching as the method embeds the Attribute interface
1515 // needed to trip the conversion to a constant.
1516 q = &evalWatchAttrQual{
1517 Attribute: qual,
1518 observer: e.observer,
1519 adapter: e.Adapter(),
1520 }
1521 default:
1522 // This is likely a custom qualifier type.
1523 q = &evalWatchQual{
1524 Qualifier: qual,
1525 observer: e.observer,
1526 adapter: e.Adapter(),
1527 }
1528 }
1529 _, err := e.InterpretableAttribute.AddQualifier(q)
1530 return e, err
1531}
1532
1533// Exec implements the InterpretableV2 interface method.
1534func (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