Class: Kind::Result::Success
- Inherits:
-
Monad
- Object
- Monad
- Kind::Result::Success
show all
- Defined in:
- lib/kind/result/success.rb
Constant Summary
collapse
- DEFAULT_TYPE =
:ok
Instance Attribute Summary
Attributes inherited from Monad
#type, #value
Instance Method Summary
collapse
Methods inherited from Monad
#===, [], #initialize, #on, #on_failure, #on_success
Methods included from Abstract
#failed?, #failure?, #on, #on_failure, #on_success, #result?, #succeeded?, #to_ary
Instance Method Details
35
36
37
|
# File 'lib/kind/result/success.rb', line 35
def inspect
'#<%s type=%p value=%p>' % ['Kind::Success', type, value]
end
|
#map(callable = UNDEFINED, &fn) ⇒ Object
Also known as:
then, and_then
15
16
17
18
19
20
21
|
# File 'lib/kind/result/success.rb', line 15
def map(callable = UNDEFINED, &fn)
_resolve_map(callable, fn)
rescue Kind::Monad::Error => e
raise e
rescue StandardError => e
Result::Failure[:exception, e]
end
|
#map!(callable = UNDEFINED, &fn) ⇒ Object
Also known as:
|, >>, then!, and_then!
26
27
28
|
# File 'lib/kind/result/success.rb', line 26
def map!(callable = UNDEFINED, &fn)
_resolve_map(callable, fn)
end
|
7
8
9
|
# File 'lib/kind/result/success.rb', line 7
def success?
true
end
|
#value_or(_default = UNDEFINED, &block) ⇒ Object
11
12
13
|
# File 'lib/kind/result/success.rb', line 11
def value_or(_default = UNDEFINED, &block)
@value
end
|