Class: Kernai::HashResolver
- Inherits:
-
Object
- Object
- Kernai::HashResolver
- Includes:
- CredentialResolver
- Defined in:
- lib/kernai/credential_resolver.rb
Overview
In-memory resolver for tests and scenarios. Accepts either a flat hash keyed by symbol key (applies to all skills) or a nested hash keyed by skill name then key.
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ HashResolver
constructor
A new instance of HashResolver.
- #resolve(skill_name, key) ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ HashResolver
Returns a new instance of HashResolver.
54 55 56 |
# File 'lib/kernai/credential_resolver.rb', line 54 def initialize(data = {}) @data = data end |
Instance Method Details
#resolve(skill_name, key) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/kernai/credential_resolver.rb', line 58 def resolve(skill_name, key) skill_scope = @data[skill_name.to_sym] || @data[skill_name.to_s] if skill_scope.is_a?(Hash) value = skill_scope[key.to_sym] || skill_scope[key.to_s] return value.to_s unless value.nil? end value = @data[key.to_sym] || @data[key.to_s] value&.to_s end |