Top Level Namespace
Defined Under Namespace
Modules: ResultMethods
Classes: Error, Ok, Result, ResultError
Instance Method Summary
collapse
Instance Method Details
#Capture ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/result-monad.rb', line 23
def Capture
begin
Ok(yield)
rescue StandardError => e
Error(e)
end
end
|
#Error(error) ⇒ Object
7
8
9
|
# File 'lib/result-monad.rb', line 7
def Error(error)
Error.new(error)
end
|
#Ok(value) ⇒ Object
11
12
13
|
# File 'lib/result-monad.rb', line 11
def Ok(value)
Ok.new(value)
end
|
#Test(o, e) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/result-monad.rb', line 15
def Test(o, e)
if yield
Ok(o)
else
Error(e)
end
end
|