Class: Quonfig::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/quonfig/resolver.rb

Overview

Public-API resolver: looks up a config by key in a ConfigStore and runs it through an Evaluator against a Context.

store     = Quonfig::ConfigStore.new(configs_hash)
evaluator = Quonfig::Evaluator.new(store)
resolver  = Quonfig::Resolver.new(store, evaluator)
result    = resolver.get('my.flag', context)

Mirrors the sdk-node pattern so integration tests (qfg-dk6.22-24) can drive evaluation without constructing a full Client. For the full production read path (with config_loader, SSE updates, telemetry), see Quonfig::ConfigResolver — the two coexist during the JSON migration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store, evaluator) ⇒ Resolver

Returns a new instance of Resolver.



20
21
22
23
# File 'lib/quonfig/resolver.rb', line 20

def initialize(store, evaluator)
  @store = store
  @evaluator = evaluator
end

Instance Attribute Details

#evaluatorObject (readonly)

Returns the value of attribute evaluator.



17
18
19
# File 'lib/quonfig/resolver.rb', line 17

def evaluator
  @evaluator
end

#project_env_idObject

Returns the value of attribute project_env_id.



18
19
20
# File 'lib/quonfig/resolver.rb', line 18

def project_env_id
  @project_env_id
end

#storeObject (readonly)

Returns the value of attribute store.



17
18
19
# File 'lib/quonfig/resolver.rb', line 17

def store
  @store
end

Instance Method Details

#get(key, context = nil) ⇒ Object



29
30
31
32
33
34
# File 'lib/quonfig/resolver.rb', line 29

def get(key, context = nil)
  config = raw(key)
  return nil unless config

  @evaluator.evaluate_config(config, context, resolver: self)
end

#raw(key) ⇒ Object



25
26
27
# File 'lib/quonfig/resolver.rb', line 25

def raw(key)
  @store.get(key)
end

#symbolize_json_names?Boolean

Integration shims for code that expects a ConfigResolver. Keep these narrow; the real ConfigResolver still owns the production hot path.

Returns:

  • (Boolean)


38
39
40
# File 'lib/quonfig/resolver.rb', line 38

def symbolize_json_names?
  false
end