Module: Hopscotch::Error
Overview
Error provides helper functions for working with ErrorValue (and thus ReturnValue)
Instance Method Summary collapse
-
#error?(e) ⇒ Boolean
Returns
trueifeis an error. -
#success?(e) ⇒ Boolean
Returns
falseifeis an error. -
#to_error(e) ⇒ Object
Convert
einto a value representing an error, if required.
Instance Method Details
#error?(e) ⇒ Boolean
Returns true if e is an error
20 21 22 |
# File 'lib/hopscotch/error.rb', line 20 def error?(e) ErrorValue === e end |
#success?(e) ⇒ Boolean
Returns false if e is an error
25 26 27 |
# File 'lib/hopscotch/error.rb', line 25 def success?(e) ! error?(e) end |
#to_error(e) ⇒ Object
Convert e into a value representing an error, if required.
30 31 32 33 34 35 36 37 |
# File 'lib/hopscotch/error.rb', line 30 def to_error(e) case e when ErrorValue e else ErrorValue.new(e) end end |