Class: Kobako::Wire::Envelope::Outcome

Inherits:
Data
  • Object
show all
Defined in:
lib/kobako/wire/envelope/payloads.rb

Overview

Outcome (SPEC.md Outcome Envelope)

OUTCOME_BUFFER wrapper: one-byte tag (0x01 Result, 0x02 Panic) followed by the msgpack payload of the corresponding envelope. Callers construct an Outcome by wrapping the payload directly —+Outcome.new(Result.new(value))+ or Outcome.new(panic) — so the contract reads symmetrically across both variants.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload:) ⇒ Outcome

Returns a new instance of Outcome.



98
99
100
101
102
103
104
# File 'lib/kobako/wire/envelope/payloads.rb', line 98

def initialize(payload:)
  unless payload.is_a?(Result) || payload.is_a?(Panic)
    raise ArgumentError, "Outcome payload must be Result or Panic, got #{payload.class}"
  end

  super
end

Instance Attribute Details

#payloadObject (readonly)

Returns the value of attribute payload

Returns:

  • (Object)

    the current value of payload



97
98
99
# File 'lib/kobako/wire/envelope/payloads.rb', line 97

def payload
  @payload
end

Instance Method Details

#panic?Boolean

Returns:

  • (Boolean)


107
# File 'lib/kobako/wire/envelope/payloads.rb', line 107

def panic?  = payload.is_a?(Panic)

#result?Boolean

Returns:

  • (Boolean)


106
# File 'lib/kobako/wire/envelope/payloads.rb', line 106

def result? = payload.is_a?(Result)