Class: Quonfig::Resolver
- Inherits:
-
Object
- Object
- Quonfig::Resolver
- 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
-
#evaluator ⇒ Object
readonly
Returns the value of attribute evaluator.
-
#project_env_id ⇒ Object
Returns the value of attribute project_env_id.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #get(key, context = nil) ⇒ Object
-
#initialize(store, evaluator) ⇒ Resolver
constructor
A new instance of Resolver.
- #raw(key) ⇒ Object
-
#symbolize_json_names? ⇒ Boolean
Integration shims for code that expects a ConfigResolver.
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
#evaluator ⇒ Object (readonly)
Returns the value of attribute evaluator.
17 18 19 |
# File 'lib/quonfig/resolver.rb', line 17 def evaluator @evaluator end |
#project_env_id ⇒ Object
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 |
#store ⇒ Object (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.
38 39 40 |
# File 'lib/quonfig/resolver.rb', line 38 def symbolize_json_names? false end |