Class: Temporalio::Converters::PayloadConverter::BinaryNull

Inherits:
Encoding
  • Object
show all
Defined in:
lib/temporalio/converters/payload_converter/binary_null.rb

Overview

Encoding for nil values for binary/null encoding.

Constant Summary collapse

ENCODING =
'binary/null'

Instance Method Summary collapse

Instance Method Details

#encodingString



14
15
16
# File 'lib/temporalio/converters/payload_converter/binary_null.rb', line 14

def encoding
  ENCODING
end

#from_payload(payload, hint: nil) ⇒ Object

Convert the payload to a Ruby value. The caller confirms the encoding metadata matches #encoding, so this will error if it cannot convert.



28
29
30
# File 'lib/temporalio/converters/payload_converter/binary_null.rb', line 28

def from_payload(payload, hint: nil) # rubocop:disable Lint/UnusedMethodArgument
  nil
end

#to_payload(value, hint: nil) ⇒ Api::Common::V1::Payload?

Convert value to payload if this encoding converter can handle it, or return nil. If the converter can handle it, the resulting payload must have encoding metadata on the payload set to the value of #encoding.



19
20
21
22
23
24
25
# File 'lib/temporalio/converters/payload_converter/binary_null.rb', line 19

def to_payload(value, hint: nil) # rubocop:disable Lint/UnusedMethodArgument
  return nil unless value.nil?

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