Sha256: 59fa671a6497a5c57bd49553c8ff37639235899249daaa7f58f8083de85442b3

Contents?: true

Size: 361 Bytes

Versions: 3

Compression:

Stored size: 361 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 == self.type
    end

    def value_or
      yield
    end

    alias data_or value_or
  end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bcdd-result-0.3.0 lib/bcdd/result/failure.rb
bcdd-result-0.2.0 lib/bcdd/result/failure.rb
bcdd-result-0.1.0 lib/bcdd/result/failure.rb