Sha256: bf86080bc066bd54e84f6061f04e7f4dc669a0e09b7426ed504b70e944f2a812
Contents?: true
Size: 872 Bytes
Versions: 2
Compression:
Stored size: 872 Bytes
Contents
# typed: strict # frozen_string_literal: true module Typed # Represents a successful result. Contains a payload and no error information. class Success < Result extend T::Sig extend T::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(T::Boolean) } def success? true end sig { override.returns(T::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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sorbet-result-0.2.1 | lib/typed/success.rb |
sorbet-result-0.2.0 | lib/typed/success.rb |