Sha256: d8f8f472605ac78866124579556475a585f3c23f51dfd5c86f60ba0c0756a235

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true

module Kind
  module Maybe
    class Result
      attr_reader :value

      Value = ->(arg) { arg.kind_of?(Maybe::Result) ? arg.value : arg } # :nodoc:

      def initialize(arg)
        @value = Value.(arg)
      end

      def value_or(method_name = UNDEFINED, &block)
        raise NotImplementedError
      end

      def none?
        raise NotImplementedError
      end

      def some?; !none?; end

      def map(&fn)
        raise NotImplementedError
      end

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

      def check(&fn)
        raise NotImplementedError
      end

      def try(method_name = UNDEFINED, &block)
        raise NotImplementedError
      end

      alias_method :try!, :try

      def dig(*keys)
        raise NotImplementedError
      end

      def presence
        raise NotImplementedError
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kind-5.1.0 lib/kind/core/maybe/result.rb
kind-5.0.0 lib/kind/maybe/result.rb
kind-4.1.0 lib/kind/maybe/result.rb