Class: Temporal::PayloadConverter::Bytes

Inherits:
EncodingBase show all
Defined in:
lib/temporal/payload_converter/bytes.rb

Constant Summary collapse

ENCODING =
'binary/plain'.freeze

Instance Method Summary collapse

Instance Method Details

#encodingObject



8
9
10
# File 'lib/temporal/payload_converter/bytes.rb', line 8

def encoding
  ENCODING
end

#from_payload(payload) ⇒ Object



12
13
14
# File 'lib/temporal/payload_converter/bytes.rb', line 12

def from_payload(payload)
  payload.data
end

#to_payload(data) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/temporal/payload_converter/bytes.rb', line 16

def to_payload(data)
  return nil unless data.is_a?(String) && data.encoding == Encoding::ASCII_8BIT

  Temporal::Api::Common::V1::Payload.new(
    metadata: { 'encoding' => ENCODING },
    data: data,
  )
end