Sha256: 7fa4acf581c0bf8215073824be5df562bb47b04e7edb0a6604eb90ed43872937

Contents?: true

Size: 401 Bytes

Versions: 2

Compression:

Stored size: 401 Bytes

Contents

# frozen_string_literal: true

class BCDD::Result
  class Failure < self
    def success?(_type = nil)
      false
    end

    def failure?(type = nil)
      type.nil? || type_checker.allow_failure?([type])
    end

    def value_or
      yield
    end

    private

    def name
      :failure
    end
  end

  def self.Failure(type, value = nil)
    Failure.new(type: type, value: value)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bcdd-result-0.6.0 lib/bcdd/result/failure.rb
bcdd-result-0.5.0 lib/bcdd/result/failure.rb