Sha256: b7eb910178eb44103e4a6f10860218cc3967c5daf2b790744b7383d7333961df

Contents?: true

Size: 698 Bytes

Versions: 3

Compression:

Stored size: 698 Bytes

Contents

# frozen_string_literal: true

module ReSorcery
  module Result
    class Err
      def initialize(err)
        @err = err
      end

      def and_then
        self
      end

      def map
        self
      end

      def map_error(&block)
        Err.new(block.call(@err))
      end

      def or_else(&block)
        ArgCheck['block', block.call(@err), Ok, Err]
      end

      def assign(_name)
        self
      end

      def cata(ok:, err:)
        err.call(@err)
      end

      def ==(other)
        other.class == Err && other.instance_eval { @err } == @err
      end

      def as_json(*)
        {
          kind: :err,
          value: @err,
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
re_sorcery-0.3.0 lib/re_sorcery/result/err.rb
re_sorcery-0.2.0 lib/re_sorcery/result/err.rb
re_sorcery-0.1.0 lib/re_sorcery/result/err.rb