Class: ElasticGraph::JSONIngestion::RecordPreparerFactory
- Inherits:
-
Object
- Object
- ElasticGraph::JSONIngestion::RecordPreparerFactory
- Defined in:
- elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/record_preparer_factory.rb
Overview
Provides the ability to get an ElasticGraph::Indexer::RecordPreparer for a specific JSON schema version,
deriving each version's per-type field metadata from that version's JSON schemas.
Instance Method Summary collapse
-
#for_json_schema_version(json_schema_version) ⇒ ElasticGraph::Indexer::RecordPreparer
Gets the
ElasticGraph::Indexer::RecordPreparerfor the given JSON schema version. -
#for_latest_json_schema_version ⇒ ElasticGraph::Indexer::RecordPreparer
Gets the
ElasticGraph::Indexer::RecordPreparerfor the latest JSON schema version. -
#initialize(schema_artifacts) ⇒ RecordPreparerFactory
constructor
A new instance of RecordPreparerFactory.
Constructor Details
#initialize(schema_artifacts) ⇒ RecordPreparerFactory
Returns a new instance of RecordPreparerFactory.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/record_preparer_factory.rb', line 18 def initialize(schema_artifacts) @schema_artifacts = schema_artifacts scalar_types_by_name = schema_artifacts..scalar_types_by_name indexing_preparer_by_scalar_type_name = ::Hash.new do |hash, type_name| hash[type_name] = scalar_types_by_name[type_name]&.load_indexing_preparer&.extension_class end # : ::Hash[::String, SchemaArtifacts::RuntimeMetadata::extensionClass?] @preparers_by_json_schema_version = ::Hash.new do |hash, raw_version| version = raw_version # : Integer hash[version] = ElasticGraph::Indexer::RecordPreparer.new( indexing_preparer_by_scalar_type_name, (@schema_artifacts.json_schemas_for(version)) ) end end |
Instance Method Details
#for_json_schema_version(json_schema_version) ⇒ ElasticGraph::Indexer::RecordPreparer
Gets the ElasticGraph::Indexer::RecordPreparer for the given JSON schema version.
39 40 41 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/record_preparer_factory.rb', line 39 def for_json_schema_version(json_schema_version) @preparers_by_json_schema_version[json_schema_version] # : ElasticGraph::Indexer::RecordPreparer end |
#for_latest_json_schema_version ⇒ ElasticGraph::Indexer::RecordPreparer
Gets the ElasticGraph::Indexer::RecordPreparer for the latest JSON schema version. Intended primarily
for use in tests for convenience.
47 48 49 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/record_preparer_factory.rb', line 47 def for_latest_json_schema_version for_json_schema_version(@schema_artifacts.latest_json_schema_version) end |