Class: ElasticGraph::Indexer::RecordPreparer::Factory
- Inherits:
-
Object
- Object
- ElasticGraph::Indexer::RecordPreparer::Factory
- Defined in:
- lib/elastic_graph/indexer/record_preparer.rb
Overview
Provides the ability to get a ‘RecordPreparer` for a specific JSON schema version.
Instance Method Summary collapse
-
#for_json_schema_version(json_schema_version) ⇒ Object
Gets the ‘RecordPreparer` for the given JSON schema version.
-
#for_latest_json_schema_version ⇒ Object
Gets the ‘RecordPreparer` for the latest JSON schema version.
-
#initialize(schema_artifacts) ⇒ Factory
constructor
A new instance of Factory.
Constructor Details
#initialize(schema_artifacts) ⇒ Factory
Returns a new instance of Factory.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/elastic_graph/indexer/record_preparer.rb', line 16 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 @preparers_by_json_schema_version = ::Hash.new do |hash, version| hash[version] = 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) ⇒ Object
Gets the ‘RecordPreparer` for the given JSON schema version.
33 34 35 |
# File 'lib/elastic_graph/indexer/record_preparer.rb', line 33 def for_json_schema_version(json_schema_version) @preparers_by_json_schema_version[json_schema_version] end |
#for_latest_json_schema_version ⇒ Object
Gets the ‘RecordPreparer` for the latest JSON schema version. Intended primarily for use in tests for convenience.
39 40 41 |
# File 'lib/elastic_graph/indexer/record_preparer.rb', line 39 def for_latest_json_schema_version for_json_schema_version(@schema_artifacts.latest_json_schema_version) end |