Class: Kind::Result::Success
- Inherits:
-
Result::Monad
- Object
- Result::Monad
- Kind::Result::Success
- Defined in:
- lib/kind/result/success.rb
Constant Summary collapse
- DEFAULT_TYPE =
:ok
Instance Method Summary collapse
- #inspect ⇒ Object
- #map(callable = UNDEFINED, &fn) ⇒ Object (also: #then, #and_then)
- #map!(callable = UNDEFINED, &fn) ⇒ Object (also: #|, #>>, #then!, #and_then!)
- #success? ⇒ Boolean
- #value_or(_default = UNDEFINED, &block) ⇒ Object
Instance Method Details
#inspect ⇒ Object
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 |
#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 |