Class: Temporal::Client::Converter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/temporal/client/converter/base.rb

Direct Known Subclasses

Composite

Instance Method Summary collapse

Constructor Details

#initialize(payload_converter:) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/temporal/client/converter/base.rb', line 5

def initialize(payload_converter:)
  @payload_converter = payload_converter
end

Instance Method Details

#from_payload(payload) ⇒ Object



14
15
16
# File 'lib/temporal/client/converter/base.rb', line 14

def from_payload(payload)
  payload_converter.from_payload(payload)
end

#from_payloads(payloads) ⇒ Object



9
10
11
12
# File 'lib/temporal/client/converter/base.rb', line 9

def from_payloads(payloads)
  return nil if payloads.nil?
  payloads.payloads.map(&method(:from_payload))
end

#to_payload(data) ⇒ Object



25
26
27
# File 'lib/temporal/client/converter/base.rb', line 25

def to_payload(data)
  payload_converter.to_payload(data)
end

#to_payloads(data) ⇒ Object



18
19
20
21
22
23
# File 'lib/temporal/client/converter/base.rb', line 18

def to_payloads(data)
  return nil if data.nil?
  Temporal::Api::Common::V1::Payloads.new(
    payloads: data.map(&method(:to_payload))
  )
end