Sha256: ef265c48f0afde084bbe8838b2d23c3756afc6c30fb226edd0b045a2de36923b

Contents?: true

Size: 500 Bytes

Versions: 3

Compression:

Stored size: 500 Bytes

Contents

# frozen_string_literal: true

module Kind
  module Maybe
    class Typed
      include Wrappable

      def initialize(kind)
        @kind = kind
      end

      def new(arg)
        value = Result::Value.(arg)

        @kind === value ? Maybe.some(value) : Maybe.none
      end

      alias_method :[], :new

      private

        def __call_before_expose_the_arg_in_a_block(arg)
          value = Result::Value.(arg)

          @kind === value ? value : Maybe.none
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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