Sha256: b9a2d7961fb6545087409de430822dec6c9719c19513a2be1ba36ced0ff12f82
Contents?: true
Size: 795 Bytes
Versions: 1
Compression:
Stored size: 795 Bytes
Contents
# frozen_string_literal: true 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, value end end def Success(value = Undefined, &block) v = Undefined.default(value, block || Unit) Success.new(v) end end end private def included(base) super base.include(@mod) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-monads-1.3.5 | lib/dry/monads/result/fixed.rb |