Sha256: 8af2da6b1adbbecc715fbd4cff19043edc2b32c280e60cf31eaac77b165b6901

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 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_key, flag_type: flag_type, default_value: default_value,
                                   evaluation_context: new_context, client_metadata: client_metadata,
                                   provider_metadata: provider_metadata)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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