class OpenFeature::EvaluationContext

Overview

The evaluation context provides ambient information for the purposes of flag evaluation. Contextual data may be used as the basis for targeting, including rule-based evaluation, overrides for specific subjects, or fractional flag evaluation.

The context might contain information about the end-user, the application, the host, or any other ambient data that might be useful in flag evaluation. For example, a flag system might define rules that return a specific value based on the user's email address, locale, or the time of day. The context provides this information. The context can be optionally provided at evaluation, and mutated in before hooks.

Defined in:

openfeature/evaluation.cr

Constructors

Instance Method Summary

Constructor Detail

def self.merged(*, global : EvaluationContext | Nil = OpenFeature.global_context, transaction : EvaluationContext | Nil = OpenFeature.transaction_context, client : EvaluationContext | Nil = nil, invocation : EvaluationContext | Nil = nil) : EvaluationContext #

Any fields defined in the transaction evaluation context will overwrite duplicate fields defined in the global evaluation context, any fields defined in the client evaluation context will overwrite duplicate fields defined in the transaction evaluation context, and fields defined in the invocation evaluation context will overwrite duplicate fields defined globally or on the client. Any resulting evaluation context from a before hook will overwrite duplicate fields defined globally, on the client, or in the invocation.


[View source]
def self.new(*, targeting_key : String | Nil = nil, custom_fields : CustomFields = CustomFields.new) #

[View source]
def self.new(targeting_key : String | Nil = nil, &) #

[View source]

Instance Method Detail

def custom_fields : CustomFields #

[View source]
def custom_fields=(custom_fields : CustomFields) #

[View source]
def merge(other : EvaluationContext) : EvaluationContext #

[View source]
def targeting_key : TargetingKey | Nil #

The targeting key uniquely identifies the subject (end-user, or client service) of a flag evaluation. Providers may require this field for fractional flag evaluation, rules, or overrides targeting specific users. Such providers may behave unpredictably if a targeting key is not specified at flag resolution.


[View source]
def targeting_key=(targeting_key : TargetingKey | Nil) #

The targeting key uniquely identifies the subject (end-user, or client service) of a flag evaluation. Providers may require this field for fractional flag evaluation, rules, or overrides targeting specific users. Such providers may behave unpredictably if a targeting key is not specified at flag resolution.


[View source]