Class: Fusuma::Config::ContextMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/config/context_matcher.rb

Overview

Matches context conditions for configuration lookup. Supports AND (multiple keys) and OR (array values) conditions.

Class Method Summary collapse

Class Method Details

.match?(config_context, request_context) ⇒ Boolean

Check if config context matches request context. : (Hash[untyped, untyped]?, Hash[untyped, untyped]?) -> bool

Parameters:

  • config_context (Hash, nil)

    context defined in YAML config

  • request_context (Hash, nil)

    context from runtime

Returns:

  • (Boolean)

    true if matched



14
15
16
17
18
19
20
21
# File 'lib/fusuma/config/context_matcher.rb', line 14

def match?(config_context, request_context)
  return true if config_context.nil? || config_context.empty?
  return false if request_context.nil? || request_context.empty?

  config_context.all? do |key, expected_value|
    match_value?(expected_value, request_context[key])
  end
end