Class: ETL::Processor::TruncateProcessor
- Defined in:
- lib/etl/processor/truncate_processor.rb
Overview
A processor which will truncate a table. Use as a pre-processor for cleaning out a table prior to loading
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
Defines the table to truncate.
-
#target ⇒ Object
readonly
Defines the database connection to use.
Instance Method Summary collapse
-
#initialize(control, configuration) ⇒ TruncateProcessor
constructor
Initialize the processor.
- #process ⇒ Object
Constructor Details
#initialize(control, configuration) ⇒ TruncateProcessor
Initialize the processor
Options:
-
:target
: The target connection -
:table
: The table name
17 18 19 20 21 22 |
# File 'lib/etl/processor/truncate_processor.rb', line 17 def initialize(control, configuration) super #@file = File.join(File.dirname(control.file), configuration[:file]) @target = configuration[:target] || {} @table = configuration[:table] end |
Instance Attribute Details
#table ⇒ Object (readonly)
Defines the table to truncate
7 8 9 |
# File 'lib/etl/processor/truncate_processor.rb', line 7 def table @table end |
#target ⇒ Object (readonly)
Defines the database connection to use
10 11 12 |
# File 'lib/etl/processor/truncate_processor.rb', line 10 def target @target end |
Instance Method Details
#process ⇒ Object
24 25 26 27 |
# File 'lib/etl/processor/truncate_processor.rb', line 24 def process conn = ETL::Engine.connection(target) conn.truncate(table_name) end |