Class: ETL::Batch::Batch
Instance Attribute Summary collapse
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#file ⇒ Object
Returns the value of attribute file.
Class Method Summary collapse
-
.resolve(batch, engine) ⇒ Object
Resolve the given object to an ETL::Control::Control instance.
Instance Method Summary collapse
- #after_execute ⇒ Object
- #before_execute ⇒ Object
- #directives ⇒ Object
- #execute ⇒ Object
-
#initialize(file) ⇒ Batch
constructor
A new instance of Batch.
- #run(file) ⇒ Object
- #use_temp_tables(value = true) ⇒ Object
Constructor Details
#initialize(file) ⇒ Batch
Returns a new instance of Batch.
74 75 76 |
# File 'lib/etl/batch/batch.rb', line 74 def initialize(file) @file = file end |
Instance Attribute Details
#engine ⇒ Object
Returns the value of attribute engine.
36 37 38 |
# File 'lib/etl/batch/batch.rb', line 36 def engine @engine end |
#file ⇒ Object
Returns the value of attribute file.
35 36 37 |
# File 'lib/etl/batch/batch.rb', line 35 def file @file end |
Class Method Details
.resolve(batch, engine) ⇒ Object
Resolve the given object to an ETL::Control::Control instance. Acceptable arguments are:
-
The path to a control file as a String
-
A File object referencing the control file
-
The ETL::Control::Control object (which will just be returned)
Raises a ControlError if any other type is given
46 47 48 49 50 |
# File 'lib/etl/batch/batch.rb', line 46 def resolve(batch, engine) batch = do_resolve(batch) batch.engine = engine batch end |
Instance Method Details
#after_execute ⇒ Object
105 106 107 108 |
# File 'lib/etl/batch/batch.rb', line 105 def after_execute ETL::Engine.finish # TODO: should be moved to the directive? ETL::Engine.use_temp_tables = false # reset the temp tables end |
#before_execute ⇒ Object
101 102 103 |
# File 'lib/etl/batch/batch.rb', line 101 def before_execute end |
#directives ⇒ Object
97 98 99 |
# File 'lib/etl/batch/batch.rb', line 97 def directives @directives ||= [] end |
#execute ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/etl/batch/batch.rb', line 86 def execute engine.say "Executing batch" before_execute directives.each do |directive| directive.execute end engine.say "Finishing batch" after_execute engine.say "Batch complete" end |
#run(file) ⇒ Object
78 79 80 |
# File 'lib/etl/batch/batch.rb', line 78 def run(file) directives << Run.new(self, file) end |
#use_temp_tables(value = true) ⇒ Object
82 83 84 |
# File 'lib/etl/batch/batch.rb', line 82 def use_temp_tables(value = true) directives << UseTempTables.new(self) end |