Class: Alchemrest::Result::Error
Instance Method Summary
collapse
Error, Ok, [], for, #transform, #unwrap_or_raise!, #unwrap_or_rescue
Constructor Details
#initialize(error) ⇒ Error
rubocop:disable Lint/MissingSuper
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/alchemrest/result.rb', line 33
def initialize(error) case error
when String
self.error = Alchemrest::Error.new(error)
when *Alchemrest.rescuable_exceptions
self.error = error
else
raise ArgumentError, "Error must be a string or one of the types defined in Alchemrest.rescuable_exceptions"
end
end
|
Instance Method Details
#==(other) ⇒ Object
44
45
46
|
# File 'lib/alchemrest/result.rb', line 44
def ==(other)
other.is_a?(Error) && other.error == error
end
|
#deconstruct ⇒ Object
52
53
54
|
# File 'lib/alchemrest/result.rb', line 52
def deconstruct
[error]
end
|
#deconstruct_keys(_keys) ⇒ Object
56
57
58
|
# File 'lib/alchemrest/result.rb', line 56
def deconstruct_keys(_keys)
{ error: }
end
|
#ok? ⇒ Boolean
48
49
50
|
# File 'lib/alchemrest/result.rb', line 48
def ok?
false
end
|