class Fear::Failure

Constants

EXTRACTOR

Attributes

exception[R]

Public Class Methods

new(exception) click to toggle source

@param [StandardError]

# File lib/fear/failure.rb, line 19
def initialize(exception)
  @exception = exception
end

Public Instance Methods

==(other) click to toggle source

@param other [Any] @return [Boolean]

# File lib/fear/failure.rb, line 86
def ==(other)
  other.is_a?(Failure) && exception == other.exception
end
===(other) click to toggle source

Used in case statement @param other [any] @return [Boolean]

Calls superclass method
# File lib/fear/failure.rb, line 93
def ===(other)
  if other.is_a?(Failure)
    exception === other.exception
  else
    super
  end
end
deconstruct() click to toggle source

@return [<StandardError>]

# File lib/fear/failure.rb, line 110
def deconstruct
  [exception]
end
failure?() click to toggle source

@return [true]

# File lib/fear/failure.rb, line 31
def failure?
  true
end
flatten() click to toggle source

@return [Failure] self

# File lib/fear/failure.rb, line 48
def flatten
  self
end
get() click to toggle source

@raise

# File lib/fear/failure.rb, line 36
def get
  raise exception
end
inspect() click to toggle source

@return [String]

# File lib/fear/failure.rb, line 102
def inspect
  "#<Fear::Failure exception=#{exception.inspect}>"
end
Also aliased as: to_s
or_else(*args) click to toggle source

@return [Try] of calling block

Calls superclass method Fear::RightBiased::Left#or_else
# File lib/fear/failure.rb, line 41
def or_else(*args)
  super
rescue StandardError => error
  Failure.new(error)
end
recover() { |m| ... } click to toggle source

@yieldparam [Fear::PatternMatch] @yieldreturn [any] @return [Fear::Try]

# File lib/fear/failure.rb, line 71
def recover
  Fear.matcher { |m| yield(m) }
    .and_then { |v| Success.new(v) }
    .call_or_else(exception) { self }
rescue StandardError => error
  Failure.new(error)
end
recover_with() { |m| ... } click to toggle source

@yieldparam [Fear::PatternMatch] @yieldreturn [Fear::Try] @return [Fear::Try]

# File lib/fear/failure.rb, line 60
def recover_with
  Fear.matcher { |m| yield(m) }
    .and_then { |result| result.tap { Utils.assert_type!(result, Success, Failure) } }
    .call_or_else(exception) { self }
rescue StandardError => error
  Failure.new(error)
end
select() click to toggle source

@return [Failure] self

# File lib/fear/failure.rb, line 53
def select
  self
end
success?() click to toggle source

@return [Boolean]

# File lib/fear/failure.rb, line 26
def success?
  false
end
to_either() click to toggle source

@return [Left]

# File lib/fear/failure.rb, line 80
def to_either
  Left.new(exception)
end
to_s()

@return [String]

Alias for: inspect