Class: Julewire::Core::Execution::ScopeSnapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/julewire/core/execution/scope_snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execution: {}, carry: {}, attributes: {}, labels: {}, neutral: {}, lineage: nil) ⇒ ScopeSnapshot

Returns a new instance of ScopeSnapshot.



10
11
12
13
14
15
16
17
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 10

def initialize(execution: {}, carry: {}, attributes: {}, labels: {}, neutral: {}, lineage: nil)
  @execution = normalized_hash(execution)
  @carry = normalized_hash(carry)
  @attributes = normalized_hash(attributes)
  @neutral = normalized_hash(neutral)
  @labels = normalized_hash(labels)
  @lineage = lineage || Lineage.from_execution_hash(@execution)
end

Instance Attribute Details

#lineageObject (readonly)

Returns the value of attribute lineage.



27
28
29
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 27

def lineage
  @lineage
end

Instance Method Details

#attributes_hashObject



47
48
49
50
51
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 47

def attributes_hash
  return {} if @attributes.empty?

  Fields::FieldSet.deep_dup(@attributes)
end

#carry_hashObject



41
42
43
44
45
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 41

def carry_hash
  return {} if @carry.empty?

  Fields::FieldSet.deep_dup(@carry)
end

#context_hashObject



39
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 39

def context_hash = {}

#execution_hashObject



19
20
21
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 19

def execution_hash
  Fields::FieldSet.deep_dup(frozen_execution_hash)
end

#execution_reference_for_childObject



75
76
77
78
79
80
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 75

def execution_reference_for_child
  reference = {}
  reference[:type] = @execution[:type] if @execution.key?(:type)
  reference[:id] = @execution[:id] if @execution.key?(:id)
  reference.empty? ? nil : Fields::Internal.frozen_copy(reference)
end

#finished_atObject



35
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 35

def finished_at = nil

#frozen_execution_hashObject



23
24
25
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 23

def frozen_execution_hash
  @frozen_execution_hash ||= Fields::Internal.frozen_copy(@execution)
end

#frozen_labels_hashObject



69
70
71
72
73
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 69

def frozen_labels_hash
  return EMPTY_HASH if @labels.empty?

  @frozen_labels_hash ||= Fields::Internal.frozen_copy(@labels)
end

#idObject



29
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 29

def id = @execution[:id]

#labels_hashObject



59
60
61
62
63
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 59

def labels_hash
  return {} if @labels.empty?

  Fields::FieldSet.deep_dup(@labels)
end

#metrics_hashObject



67
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 67

def metrics_hash = {}

#neutral_hashObject



53
54
55
56
57
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 53

def neutral_hash
  return {} if @neutral.empty?

  Fields::FieldSet.deep_dup(@neutral)
end

#parentObject



37
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 37

def parent = nil

#started_atObject



33
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 33

def started_at = nil

#summary_hashObject



65
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 65

def summary_hash = {}

#typeObject



31
# File 'lib/julewire/core/execution/scope_snapshot.rb', line 31

def type = @execution[:type]