Sha256: c319a549f634b76e1ac14417a0fd3dc1937d26c98f35266c8d5ca8111f7bcbf4

Contents?: true

Size: 562 Bytes

Versions: 11

Compression:

Stored size: 562 Bytes

Contents

# frozen_string_literal: true

require 'kind/basic'

module Kind
  module Result
    require 'kind/result/abstract'
    require 'kind/result/monad'
    require 'kind/result/failure'
    require 'kind/result/success'
    require 'kind/result/methods'

    extend self

    def new(value)
      Success[value]
    end

    alias_method :[], :new

    def self.from
      result = yield

      Result::Monad === result ? result : Result::Success[result]
    rescue StandardError => e
      Result::Failure[:exception, e]
    end
  end

  extend Result::Methods
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
kind-5.10.0 lib/kind/result.rb
kind-5.9.0 lib/kind/result.rb
kind-5.8.1 lib/kind/result.rb
kind-5.8.0 lib/kind/result.rb
kind-5.7.0 lib/kind/result.rb
kind-5.6.0 lib/kind/result.rb
kind-5.5.0 lib/kind/result.rb
kind-5.4.1 lib/kind/result.rb
kind-5.4.0 lib/kind/result.rb
kind-5.3.0 lib/kind/result.rb
kind-5.2.0 lib/kind/result.rb