Class: ElasticGraph::SchemaArtifacts::RuntimeMetadata::Enum::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_graph/schema_artifacts/runtime_metadata/enum.rb

Overview

Runtime metadata related to an ElasticGraph enum value.

Constant Summary collapse

DATASTORE_VALUE =
"datastore_value"
DATASTORE_ABBREVIATION =
"datastore_abbreviation"
SORT_FIELD =
"sort_field"
ALTERNATE_ORIGINAL_NAME =
"alternate_original_name"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/enum.rb', line 48

def self.from_hash(hash)
  new(
    sort_field: hash[SORT_FIELD]&.then { |h| SortField.from_hash(h) },
    datastore_value: hash[DATASTORE_VALUE],
    datastore_abbreviation: hash[DATASTORE_ABBREVIATION]&.to_sym,
    alternate_original_name: hash[ALTERNATE_ORIGINAL_NAME]
  )
end

Instance Method Details

#to_dumpable_hashObject



57
58
59
60
61
62
63
64
65
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/enum.rb', line 57

def to_dumpable_hash
  {
    # Keys here are ordered alphabetically; please keep them that way.
    DATASTORE_ABBREVIATION => datastore_abbreviation&.to_s,
    DATASTORE_VALUE => datastore_value,
    ALTERNATE_ORIGINAL_NAME => alternate_original_name,
    SORT_FIELD => sort_field&.to_dumpable_hash
  }
end