Class: SimpleResult::Failure

Inherits:
Response
  • Object
show all
Defined in:
lib/simple_result.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error: nil) ⇒ Failure

Returns a new instance of Failure.



40
# File 'lib/simple_result.rb', line 40

def initialize(error: nil) = super(payload: nil, error: error)

Class Method Details

.blankObject



39
# File 'lib/simple_result.rb', line 39

def self.blank             = new(error: nil)

Instance Method Details

#and_thenObject



47
# File 'lib/simple_result.rb', line 47

def and_then(&) = self

#failure?Boolean

Returns:

  • (Boolean)


43
# File 'lib/simple_result.rb', line 43

def failure?   = true

#inspectObject



54
# File 'lib/simple_result.rb', line 54

def inspect = "#<data #{self.class.name} error=#{error.inspect}>"

#on_error {|error| ... } ⇒ Object

Yields:

  • (error)


49
50
51
52
# File 'lib/simple_result.rb', line 49

def on_error(&)
  yield(error)
  self
end

#payloadObject

Raises:



44
# File 'lib/simple_result.rb', line 44

def payload    = raise(ResponseError, 'Payload not present on failure')

#payload_or_fallbackObject



46
# File 'lib/simple_result.rb', line 46

def payload_or_fallback(&) = yield

#pretty_print(pp) ⇒ Object



55
# File 'lib/simple_result.rb', line 55

def pretty_print(pp) = pp.text "#<data #{self.class.name} error=#{error.inspect}>"

#success?Boolean

Returns:

  • (Boolean)


42
# File 'lib/simple_result.rb', line 42

def success?   = false