Class: Result::With

Inherits:
Object
  • Object
show all
Defined in:
lib/result/with.rb

Instance Method Summary collapse

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

#mapObject



23
24
25
26
27
# File 'lib/result/with.rb', line 23

def map
  run.map do |results|
    yield *results
  end
end

#thenObject



11
12
13
14
15
# File 'lib/result/with.rb', line 11

def then
  run.then do |results|
    yield *results
  end
end

#when_okObject



17
18
19
20
21
# File 'lib/result/with.rb', line 17

def when_ok
  run.when_ok do |results|
    yield *results
  end
end