Sha256: fa55f6f1585c8f14e871853ddb0e4f9db0f3723b2fea3575ef8d8335d51dac32
Contents?: true
Size: 853 Bytes
Versions: 1
Compression:
Stored size: 853 Bytes
Contents
# typed: strict # frozen_string_literal: true module T # Represents a successful result. Contains a payload and no error information. class Success extend Sig extend Generic include Result Payload = type_member Error = type_member sig { override.returns(T.nilable(Payload)) } attr_reader :payload sig { params(payload: T.nilable(Payload)).void } def initialize(payload: nil) @payload = payload end sig { override.returns(Boolean) } def success? true end sig { override.returns(Boolean) } def failure? false end sig { override.returns(NilClass) } def error nil end sig { override.returns(Payload) } def payload! case @payload when nil raise NilPayloadError else @payload end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sorbet-result-0.1.0 | lib/t/success.rb |