Class: ElasticGraph::QueryInterceptor::Config
- Inherits:
-
Object
- Object
- ElasticGraph::QueryInterceptor::Config
- Defined in:
- lib/elastic_graph/query_interceptor/config.rb
Overview
Defines configuration for elasticgraph-query_interceptor
Defined Under Namespace
Classes: InterceptorInterface
Constant Summary collapse
- DEFAULT =
new([])
- EXPECTED_KEYS =
members.map(&:to_s)
- InterceptorData =
Defines a data structure to hold interceptor klass and config
::Data.define(:klass, :config)
Class Method Summary collapse
-
.from_parsed_yaml(parsed_config_hash, parsed_runtime_metadata_hashes: []) ⇒ Object
Builds Config from parsed YAML config.
Class Method Details
.from_parsed_yaml(parsed_config_hash, parsed_runtime_metadata_hashes: []) ⇒ Object
Builds Config from parsed YAML config.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/elastic_graph/query_interceptor/config.rb', line 16 def self.from_parsed_yaml(parsed_config_hash, parsed_runtime_metadata_hashes: []) interceptor_hashes = .flat_map { |h| h["interceptors"] || [] } if (extension_config = parsed_config_hash["query_interceptor"]) extra_keys = extension_config.keys - EXPECTED_KEYS unless extra_keys.empty? raise ConfigError, "Unknown `query_interceptor` config settings: #{extra_keys.join(", ")}" end interceptor_hashes += extension_config.fetch("interceptors") end loader = SchemaArtifacts::RuntimeMetadata::ExtensionLoader.new(InterceptorInterface) interceptors = interceptor_hashes.map do |hash| empty_config = {} # : ::Hash[::Symbol, untyped] ext = loader.load(hash.fetch("extension_name"), from: hash.fetch("require_path"), config: empty_config) config = hash["config"] || {} # : ::Hash[::String, untyped] InterceptorData.new(klass: ext.extension_class, config: config) end new(interceptors) end |