Class: LightService::Organizer::Iterate

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

Class Method Summary collapse

Methods included from ScopedReducable

scoped_reduce

Class Method Details

.run(organizer, collection_key, steps) ⇒ Object



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

def self.run(organizer, collection_key, steps)
  lambda do |ctx|
    return ctx if ctx.stop_processing?

    collection = ctx[collection_key]
    item_key = collection_key.to_s.singularize.to_sym
    collection.each do |item|
      ctx[item_key] = item
      ctx = scoped_reduce(organizer, ctx, steps)
    end

    ctx
  end
end