Sha256: 509cc1737ddddcf5072bea5364d64e84fd11488bab4a4494d4550db836239b0d
Contents?: true
Size: 856 Bytes
Versions: 1
Compression:
Stored size: 856 Bytes
Contents
# typed: strict # frozen_string_literal: true module T # Represents a successful result. Contains a payload and no error information. class Success < Result extend Sig extend Generic 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 super() 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.1 | lib/t/success.rb |