Class: ArcFurnace::BlockObserver

Inherits:
Observer show all
Defined in:
lib/arc-furnace/block_observer.rb

Instance Attribute Summary

Attributes inherited from Node

#error_handler, #node_id, #params

Instance Method Summary collapse

Methods inherited from Observer

#value

Methods inherited from Source

#advance, #close, #empty?, #finalize, #prepare, #row, #value

Constructor Details

#initialize(source:, block:) ⇒ BlockObserver

Returns a new instance of BlockObserver.



7
8
9
10
11
# File 'lib/arc-furnace/block_observer.rb', line 7

def initialize(source:, block:)
  raise 'Must specify a block' if block.nil?
  @block = block
  super(source: source)
end

Instance Method Details

#observe(row) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/arc-furnace/block_observer.rb', line 13

def observe(row)
  if block.arity == 2
    block.call(row, params)
  else
    block.call(row)
  end
end