Class: ETL::Batch::Batch

Inherits:
Object show all
Defined in:
lib/etl/batch/batch.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#engineObject

Returns the value of attribute engine



36
37
38
# File 'lib/etl/batch/batch.rb', line 36

def engine
  @engine
end

#fileObject

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_executeObject



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_executeObject



101
102
103
# File 'lib/etl/batch/batch.rb', line 101

def before_execute
  
end

#directivesObject



97
98
99
# File 'lib/etl/batch/batch.rb', line 97

def directives
  @directives ||= []
end

#executeObject



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