Class: ElasticGraph::SchemaArtifacts::RuntimeMetadata::UpdateTarget

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

Overview

Provides runtime metadata related to the targets of datastore update calls.

Constant Summary collapse

TYPE =
"type"
RELATIONSHIP =
"relationship"
SCRIPT_ID =
"script_id"
ID_SOURCE =
"id_source"
ROUTING_VALUE_SOURCE =
"routing_value_source"
ROLLOVER_TIMESTAMP_VALUE_SOURCE =
"rollover_timestamp_value_source"
DATA_PARAMS =
"data_params"
METADATA_PARAMS =
"metadata_params"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/update_target.rb', line 35

def self.from_hash(hash)
  new(
    type: hash[TYPE],
    relationship: hash[RELATIONSHIP],
    script_id: hash[SCRIPT_ID],
    id_source: hash[ID_SOURCE],
    routing_value_source: hash[ROUTING_VALUE_SOURCE],
    rollover_timestamp_value_source: hash[ROLLOVER_TIMESTAMP_VALUE_SOURCE],
    data_params: Param.load_params_hash(hash[DATA_PARAMS] || {}),
    metadata_params: Param.load_params_hash(hash[] || {})
  )
end

Instance Method Details

#for_normal_indexing?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/update_target.rb', line 62

def for_normal_indexing?
  script_id == INDEX_DATA_UPDATE_SCRIPT_ID
end

#params_for(doc_id:, event:, prepared_record:) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/update_target.rb', line 66

def params_for(doc_id:, event:, prepared_record:)
  data = data_params.to_h do |name, param|
    [name, param.value_for(prepared_record)]
  end

  meta = .to_h do |name, param|
    [name, param.value_for(event)]
  end

  meta.merge({"id" => doc_id, "data" => data})
end

#to_dumpable_hashObject



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/update_target.rb', line 48

def to_dumpable_hash
  {
    # Keys here are ordered alphabetically; please keep them that way.
    DATA_PARAMS => Param.dump_params_hash(data_params),
    ID_SOURCE => id_source,
     => Param.dump_params_hash(),
    RELATIONSHIP => relationship,
    ROLLOVER_TIMESTAMP_VALUE_SOURCE => rollover_timestamp_value_source,
    ROUTING_VALUE_SOURCE => routing_value_source,
    SCRIPT_ID => script_id,
    TYPE => type
  }
end