Sha256: 862811b41e035b5f3ca9ec44e27534306ea3ea48a391e08edf09ee31d5312c80

Contents?: true

Size: 577 Bytes

Versions: 25

Compression:

Stored size: 577 Bytes

Contents

# frozen_string_literal: true

require "dry/monads/result"

module Dry
  module Schema
    # Monad extension for Result
    #
    # @api public
    class Result
      include Dry::Monads::Result::Mixin

      # Turn result into a monad
      #
      # This makes result objects work with dry-monads (or anything with a compatible interface)
      #
      # @return [Dry::Monads::Success,Dry::Monads::Failure]
      #
      # @api public
      def to_monad
        if success?
          Success(self)
        else
          Failure(self)
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
dry-schema-1.11.1 lib/dry/schema/extensions/monads.rb
dry-schema-1.11.0 lib/dry/schema/extensions/monads.rb
dry-schema-1.10.6 lib/dry/schema/extensions/monads.rb
dry-schema-1.10.5 lib/dry/schema/extensions/monads.rb
dry-schema-1.10.4 lib/dry/schema/extensions/monads.rb
dry-schema-1.10.3 lib/dry/schema/extensions/monads.rb
dry-schema-1.10.2 lib/dry/schema/extensions/monads.rb
dry-schema-1.10.1 lib/dry/schema/extensions/monads.rb
dry-schema-1.9.3 lib/dry/schema/extensions/monads.rb
dry-schema-1.9.2 lib/dry/schema/extensions/monads.rb
dry-schema-1.9.1 lib/dry/schema/extensions/monads.rb
dry-schema-1.9.0 lib/dry/schema/extensions/monads.rb
dry-schema-1.8.0 lib/dry/schema/extensions/monads.rb
dry-schema-1.7.1 lib/dry/schema/extensions/monads.rb
dry-schema-1.7.0 lib/dry/schema/extensions/monads.rb
dry-schema-1.6.2 lib/dry/schema/extensions/monads.rb
dry-schema-1.6.1 lib/dry/schema/extensions/monads.rb
dry-schema-1.6.0 lib/dry/schema/extensions/monads.rb
dry-schema-1.5.6 lib/dry/schema/extensions/monads.rb
dry-schema-1.5.5 lib/dry/schema/extensions/monads.rb