Sha256: 13ef460713d53c4e4ddc22b7f3811fe5617b410885a9a551f2257f5346500492

Contents?: true

Size: 701 Bytes

Versions: 6

Compression:

Stored size: 701 Bytes

Contents

module Dry::Monads
  class Result
    # @see Monads#Result
    # @private
    class Fixed < Module
      def self.[](error, **options)
        new(error, **options)
      end

      def initialize(error, **options)
        @mod = Module.new do
          define_method(:Failure) do |value|
            if error === value
              Failure.new(value, RightBiased::Left.trace_caller)
            else
              raise InvalidFailureTypeError.new(value)
            end
          end

          def Success(value)
            Success.new(value)
          end
        end
      end

      # @api private
      def included(base)
        super

        base.include(@mod)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-monads-1.0.1 lib/dry/monads/result/fixed.rb
dry-monads-1.0.0 lib/dry/monads/result/fixed.rb
dry-monads-1.0.0.rc1 lib/dry/monads/result/fixed.rb
dry-monads-1.0.0.beta3 lib/dry/monads/result/fixed.rb
dry-monads-1.0.0.beta2 lib/dry/monads/result/fixed.rb
dry-monads-1.0.0.beta1 lib/dry/monads/result/fixed.rb