Class: LazierData::Processor::ChildEach

Inherits:
Object
  • Object
show all
Defined in:
lib/lazier_data/processor/child_each.rb

Constant Summary collapse

NOTHING =
:_lazier_data_nothing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(upstream, downstream, input_path, &block) ⇒ ChildEach

Returns a new instance of ChildEach.



10
11
12
13
14
15
16
# File 'lib/lazier_data/processor/child_each.rb', line 10

def initialize(upstream, downstream, input_path, &block)
  @upstream = upstream
  @downstream = downstream
  @batch_size = nil
  @input_path = input_path
  @block = block
end

Instance Attribute Details

#batch_sizeObject (readonly)

Returns the value of attribute batch_size.



8
9
10
# File 'lib/lazier_data/processor/child_each.rb', line 8

def batch_size
  @batch_size
end

#blockObject (readonly)

Returns the value of attribute block.



8
9
10
# File 'lib/lazier_data/processor/child_each.rb', line 8

def block
  @block
end

#downstreamObject (readonly)

Returns the value of attribute downstream.



8
9
10
# File 'lib/lazier_data/processor/child_each.rb', line 8

def downstream
  @downstream
end

#input_pathObject (readonly)

Returns the value of attribute input_path.



8
9
10
# File 'lib/lazier_data/processor/child_each.rb', line 8

def input_path
  @input_path
end

#upstreamObject (readonly)

Returns the value of attribute upstream.



8
9
10
# File 'lib/lazier_data/processor/child_each.rb', line 8

def upstream
  @upstream
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
# File 'lib/lazier_data/processor/child_each.rb', line 18

def call
  upstream.each do |root_item, item_store|
    output_yielders = build_output_yielders(item_store)
    item_store.dig(*input_path).each do |item|
      block.call(item, *output_yielders)
    end
    downstream << [root_item, item_store]
  end
end