Class: FunctionalLightService::Organizer::ReduceUntil

Inherits:
Object
  • Object
show all
Extended by:
ScopedReducable
Defined in:
lib/functional-light-service/organizer/reduce_until.rb

Class Method Summary collapse

Methods included from ScopedReducable

scoped_reduce

Class Method Details

.run(organizer, condition_block, steps) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/functional-light-service/organizer/reduce_until.rb', line 6

def self.run(organizer, condition_block, steps)
  ->(ctx) do
    return ctx if ctx.stop_processing?

    loop do
      ctx = scoped_reduce(organizer, ctx, steps)
      break if condition_block.call(ctx) || ctx.failure?
    end

    ctx
  end
end