Class: Might::Failure
Overview
Represents fetching failure
Instance Attribute Summary collapse
- #errors ⇒ Object readonly
Instance Method Summary collapse
- #failure? ⇒ true
- #get ⇒ Object
- #get_or_else { ... } ⇒ Object
-
#initialize(errors) ⇒ Failure
constructor
A new instance of Failure.
- #success? ⇒ false
Constructor Details
#initialize(errors) ⇒ Failure
Returns a new instance of Failure.
12 13 14 |
# File 'lib/might/result.rb', line 12 def initialize(errors) @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
17 18 19 |
# File 'lib/might/result.rb', line 17 def errors @errors end |
Instance Method Details
#failure? ⇒ true
20 21 22 |
# File 'lib/might/result.rb', line 20 def failure? !success? end |
#get ⇒ Object
30 31 32 33 34 35 |
# File 'lib/might/result.rb', line 30 def get fail NotImplementedError, <<-MESSAGE.strip_heredoc #{self.class} does not respond to #get. You should explicitly check for #success? before calling #get. MESSAGE end |
#get_or_else { ... } ⇒ Object
38 39 40 |
# File 'lib/might/result.rb', line 38 def get_or_else yield end |
#success? ⇒ false
25 26 27 |
# File 'lib/might/result.rb', line 25 def success? false end |