Class: ElasticGraph::SchemaArtifacts::RuntimeMetadata::IndexDefinition
- Inherits:
-
Object
- Object
- ElasticGraph::SchemaArtifacts::RuntimeMetadata::IndexDefinition
- Defined in:
- lib/elastic_graph/schema_artifacts/runtime_metadata/index_definition.rb
Overview
Runtime metadata related to a datastore index definition.
Defined Under Namespace
Classes: Rollover
Constant Summary collapse
- ROUTE_WITH =
"route_with"- ROLLOVER =
"rollover"- DEFAULT_SORT_FIELDS =
"default_sort_fields"- CURRENT_SOURCES =
"current_sources"- FIELDS_BY_PATH =
"fields_by_path"- HAS_HAD_MULTIPLE_SOURCES =
"has_had_multiple_sources"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(route_with:, rollover:, default_sort_fields:, current_sources:, fields_by_path:, has_had_multiple_sources:) ⇒ IndexDefinition
constructor
A new instance of IndexDefinition.
- #to_dumpable_hash ⇒ Object
Constructor Details
#initialize(route_with:, rollover:, default_sort_fields:, current_sources:, fields_by_path:, has_had_multiple_sources:) ⇒ IndexDefinition
Returns a new instance of IndexDefinition.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/index_definition.rb', line 27 def initialize(route_with:, rollover:, default_sort_fields:, current_sources:, fields_by_path:, has_had_multiple_sources:) super( route_with: route_with, rollover: rollover, default_sort_fields: default_sort_fields, current_sources: current_sources.to_set, fields_by_path: fields_by_path, has_had_multiple_sources: has_had_multiple_sources ) end |
Class Method Details
.from_hash(hash) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/index_definition.rb', line 38 def self.from_hash(hash) new( route_with: hash[ROUTE_WITH], rollover: hash[ROLLOVER]&.then { |h| Rollover.from_hash(h) }, default_sort_fields: hash[DEFAULT_SORT_FIELDS]&.map { |h| SortField.from_hash(h) } || [], current_sources: hash[CURRENT_SOURCES] || [], fields_by_path: (hash[FIELDS_BY_PATH] || {}).transform_values { |h| IndexField.from_hash(h) }, has_had_multiple_sources: hash[HAS_HAD_MULTIPLE_SOURCES] || false ) end |
Instance Method Details
#to_dumpable_hash ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/index_definition.rb', line 49 def to_dumpable_hash { # Keys here are ordered alphabetically; please keep them that way. CURRENT_SOURCES => current_sources.sort, DEFAULT_SORT_FIELDS => default_sort_fields.map(&:to_dumpable_hash), FIELDS_BY_PATH => HashDumper.dump_hash(fields_by_path, &:to_dumpable_hash), HAS_HAD_MULTIPLE_SOURCES => (true if has_had_multiple_sources), ROLLOVER => rollover&.to_dumpable_hash, ROUTE_WITH => route_with } end |