Sha256: 9e924b4c1fc9b4854af51d26a352c06c30c1a8b3ac30fb127caf519f2759d41a

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

# typed: strict
# frozen_string_literal: true

module OpenFeature
  # See https://openfeature.dev/specification/sections/hooks#41-hook-context
  # See Requirement 4.1.1, 4.1.3, 4.1.4
  # TODO: Requirement 4.1.2
  class HookContext < T::Struct
    extend T::Generic
    extend T::Sig

    include T::Struct::ActsAsComparable

    Value = type_member
    const :flag_key, String
    const :flag_type, String
    const :evaluation_context, EvaluationContext
    const :default_value, Value
    const :client_metadata, ClientMetadata
    const :provider_metadata, ProviderMetadata

    # Needed as opposed to .with due to https://sorbet.org/docs/tstruct#from_hash-gotchas
    sig { params(new_context: EvaluationContext).returns(HookContext[Value]) }
    def with_new_evaluation_context(new_context)
      OpenFeature::HookContext.new(flag_key:, flag_type:, default_value:,
                                   evaluation_context: new_context, client_metadata:,
                                   provider_metadata:)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openfeature-sdk-sorbet-0.3.1 lib/open_feature/hook_context.rb
openfeature-sdk-sorbet-0.3.0 lib/open_feature/hook_context.rb