Module: Julewire::Ractor::RemotePayload

Defined in:
lib/julewire/ractor/remote_payload.rb

Class Method Summary collapse

Class Method Details

.extract(payload) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/julewire/ractor/remote_payload.rb', line 7

def extract(payload)
  validate_hash!(payload)
  {
    input: hash_value(payload, :input),
    context: hash_value(payload, :context),
    neutral: hash_value(payload, :neutral),
    attributes: hash_value(payload, :attributes),
    carry: hash_value(payload, :carry),
    scope: scope_snapshot(hash_value(payload, :scope))
  }
end

.hash_value(hash, key) ⇒ Object



29
30
31
# File 'lib/julewire/ractor/remote_payload.rb', line 29

def hash_value(hash, key)
  validate_hash!(hash.fetch(key))
end

.scope_snapshot(scope_payload) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/julewire/ractor/remote_payload.rb', line 19

def scope_snapshot(scope_payload)
  Core::Execution::ScopeSnapshot.new(
    execution: hash_value(scope_payload, :execution),
    neutral: hash_value(scope_payload, :neutral),
    attributes: hash_value(scope_payload, :attributes),
    carry: hash_value(scope_payload, :carry),
    labels: hash_value(scope_payload, :labels)
  )
end