Class: Result::With
- Inherits:
-
Object
- Object
- Result::With
- Defined in:
- lib/result/with.rb
Instance Method Summary collapse
- #and(&block) ⇒ Object
-
#initialize(block:) ⇒ With
constructor
A new instance of With.
- #map ⇒ Object
- #then ⇒ Object
- #when_ok ⇒ Object
Constructor Details
#initialize(block:) ⇒ With
Returns a new instance of With.
2 3 4 |
# File 'lib/result/with.rb', line 2 def initialize(block:) @blocks = [block] end |
Instance Method Details
#and(&block) ⇒ Object
6 7 8 9 |
# File 'lib/result/with.rb', line 6 def and(&block) @blocks << block self end |
#map ⇒ Object
23 24 25 26 27 |
# File 'lib/result/with.rb', line 23 def map run.map do |results| yield *results end end |
#then ⇒ Object
11 12 13 14 15 |
# File 'lib/result/with.rb', line 11 def then run.then do |results| yield *results end end |
#when_ok ⇒ Object
17 18 19 20 21 |
# File 'lib/result/with.rb', line 17 def when_ok run.when_ok do |results| yield *results end end |