Class: Chicago::ETL::Sink Abstract

Inherits:
PipelineEndpoint show all
Defined in:
lib/chicago/etl/sink.rb

Overview

This class is abstract.

The destination for rows passing through a pipeline stage.

Direct Known Subclasses

ArraySink, MysqlFileSink, NullSink

Instance Attribute Summary

Attributes inherited from PipelineEndpoint

#fields

Instance Method Summary collapse

Methods inherited from PipelineEndpoint

#has_defined_fields?

Instance Method Details

#<<(row) ⇒ Object

Writes a row to this sink.

By default does nothing; may be overridden by subclasses.



40
41
# File 'lib/chicago/etl/sink.rb', line 40

def <<(row)
end

#closeObject

Performs any operations after writing rows to this sink.

By default does nothing; may be overridden by subclasses.



34
35
# File 'lib/chicago/etl/sink.rb', line 34

def close
end

#constant_valuesObject

Specifies a hash of values that are assumed to apply to all rows.

Subclasses should use there constant values appropriately when writing rows, by merging them with the row or otherwise ensuring that they end up in the final source this sink represents.



15
16
17
# File 'lib/chicago/etl/sink.rb', line 15

def constant_values
  @constant_values ||= {}
end

#openObject

Performs any operations before writing rows to this sink.

By default does nothing; may be overridden by subclasses.



28
29
# File 'lib/chicago/etl/sink.rb', line 28

def open
end

#set_constant_values(hash = {}) ⇒ Object

Sets a number of constant values.



20
21
22
23
# File 'lib/chicago/etl/sink.rb', line 20

def set_constant_values(hash={})
  constant_values.merge!(hash)
  self
end

#truncateObject

Removes all rows from this sink.

This includes all rows written prior to this particular execution of a pipeline stage.

By default does nothing; should be overritten by subclasses.



49
50
# File 'lib/chicago/etl/sink.rb', line 49

def truncate
end