Sha256: 37a154a4f7e9b3e63aa384842dfcab949ce9a082a7cc7d1c22a53355c8a7ecbf

Contents?: true

Size: 610 Bytes

Versions: 1

Compression:

Stored size: 610 Bytes

Contents

# frozen_string_literal: true

module Kind
  class Result::Failure < Result::Monad
    DEFAULT_TYPE = :error

    def failure?
      true
    end

    def value_or(default = UNDEFINED, &block)
      Error.invalid_default_arg! if UNDEFINED == default && !block

      UNDEFINED != default ? default : block.call
    end

    def map(&_)
      self
    end

    alias_method :map!, :map
    alias_method :then, :map
    alias_method :then!, :map
    alias_method :and_then, :map
    alias_method :and_then!, :map

    def inspect
      '#<%s type=%p value=%p>' % ['Kind::Failure', type, value]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kind-5.2.0 lib/kind/result/failure.rb