class Dry::Monads::Validated::Invalid

Invalid result

Attributes

error[R]

The value stored inside

@return [Object]

trace[R]

Line where the value was constructed

@return [String] @api public

Private Class Methods

new(error, trace = RightBiased::Left.trace_caller) click to toggle source
Calls superclass method
# File lib/dry/monads/validated.rb, line 154
def initialize(error, trace = RightBiased::Left.trace_caller)
  super()

  @error = error
  @trace = trace
end

Private Instance Methods

===(other) click to toggle source

@param other [Object] @return [Boolean]

# File lib/dry/monads/validated.rb, line 222
def ===(other)
  other.instance_of?(self.class) && error === other.error
end
alt_map(proc = Undefined, &block) click to toggle source

Lifts a block/proc over Invalid

@overload alt_map(proc)

@param proc [#call]
@return [Validated::Invalid]

@overload alt_map

@param block [Proc]
@return [Validated::Invalid]
# File lib/dry/monads/validated.rb, line 188
def alt_map(proc = Undefined, &block)
  f = Undefined.default(proc, block)
  self.class.new(f.(error), RightBiased::Left.trace_caller)
end
apply(val = Undefined, &block) click to toggle source

Collects errors (ignores valid results)

@overload apply(val)

@param val [Validated::Valid,Validated::Invalid]
@return [Validated::Invalid]

@overload apply

@yieldreturn [Validated::Valid,Validated::Invalid]
@return [Validated::Invalid]
# File lib/dry/monads/validated.rb, line 171
def apply(val = Undefined, &block)
  Undefined
    .default(val, &block)
    .alt_map { @error + _1 }
    .fmap { return self }
end
fmap(_ = nil) click to toggle source

Ignores the passed argument and returns self

@return [Validated::Invalid]

# File lib/dry/monads/validated.rb, line 196
def fmap(_ = nil)
  self
end
inspect() click to toggle source

@return [String]

# File lib/dry/monads/validated.rb, line 215
def inspect
  "Invalid(#{@error.inspect})"
end
Also aliased as: to_s
or(proc = Undefined, &block) click to toggle source

Yields the given callable and returns the result

@overload or(proc)

@param proc [#call]
@return [Object]

@overload or

@param block [Proc]
@return [Object]
# File lib/dry/monads/validated.rb, line 210
def or(proc = Undefined, &block)
  Undefined.default(proc, block).call
end
to_maybe() click to toggle source

Converts to Maybe::None

@return [Maybe::None]

# File lib/dry/monads/maybe.rb, line 445
def to_maybe
  Maybe::None.new(RightBiased::Left.trace_caller)
end
to_result() click to toggle source

Converts to Result::Failure

@return [Result::Failure]

# File lib/dry/monads/result.rb, line 472
def to_result
  Result::Failure.new(error, RightBiased::Left.trace_caller)
end
to_s()
Alias for: inspect