Class: Temporal::Client::Converter::Payload::Bytes

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

Constant Summary collapse

ENCODING =
'binary/plain'.freeze

Instance Method Summary collapse

Instance Method Details

#encodingObject



10
11
12
# File 'lib/temporal/client/converter/payload/bytes.rb', line 10

def encoding
  ENCODING
end

#from_payload(payload) ⇒ Object



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

def from_payload(payload)
  payload.data
end

#to_payload(data) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/temporal/client/converter/payload/bytes.rb', line 18

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