Class: OpenFeatureSorbet::EvaluationContextBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/open_feature_sorbet/evaluation_context_builder.rb

Overview

Used to combine evaluation contexts from different sources

Instance Method Summary collapse

Instance Method Details

#call(global_context:, client_context:, invocation_context:) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/open_feature_sorbet/evaluation_context_builder.rb', line 16

def call(global_context:, client_context:, invocation_context:)
  available_contexts = [global_context, client_context, invocation_context].compact

  return nil if available_contexts.empty?

  available_contexts.reduce(EvaluationContext.new) do |built_context, context|
    built_context.merge(context)
  end
end