Class: SimpleResult::Failure
Class Method Summary collapse
Instance Method Summary collapse
- #and_then ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(error: nil) ⇒ Failure
constructor
A new instance of Failure.
- #inspect ⇒ Object
- #on_error {|error| ... } ⇒ Object
- #payload ⇒ Object
- #payload_or_fallback ⇒ Object
- #pretty_print(pp) ⇒ Object
- #success? ⇒ Boolean
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
.blank ⇒ Object
39 |
# File 'lib/simple_result.rb', line 39 def self.blank = new(error: nil) |
Instance Method Details
#and_then ⇒ Object
47 |
# File 'lib/simple_result.rb', line 47 def and_then(&) = self |
#failure? ⇒ Boolean
43 |
# File 'lib/simple_result.rb', line 43 def failure? = true |
#inspect ⇒ Object
54 |
# File 'lib/simple_result.rb', line 54 def inspect = "#<data #{self.class.name} error=#{error.inspect}>" |
#on_error {|error| ... } ⇒ Object
49 50 51 52 |
# File 'lib/simple_result.rb', line 49 def on_error(&) yield(error) self end |
#payload ⇒ Object
44 |
# File 'lib/simple_result.rb', line 44 def payload = raise(ResponseError, 'Payload not present on failure') |
#payload_or_fallback ⇒ Object
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
42 |
# File 'lib/simple_result.rb', line 42 def success? = false |