Class: DataDuck::Destination
Instance Attribute Summary
Attributes inherited from Database
#name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Database
#connection, #initialize, #query, #table_names
Class Method Details
.destination(name, allow_nil = false) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/dataduck/destination.rb', line 41
def self.destination(name, allow_nil = false)
name = name.to_s
if DataDuck.destinations[name]
return DataDuck.destinations[name]
elsif allow_nil
return nil
else
raise "Could not find destination #{ name } in destination configs."
end
end
|
.destination_config(name) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/dataduck/destination.rb', line 21
def self.destination_config(name)
if DataDuck.config['destinations'].nil? || DataDuck.config['destinations'][name.to_s].nil?
raise "Could not find destination #{ name } in destinations configs."
end
DataDuck.config['destinations'][name.to_s]
end
|
.load_config! ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/dataduck/destination.rb', line 5
def self.load_config!
all_config = DataDuck.config['destinations']
return if all_config.nil?
all_config.each_key do |destination_name|
configuration = all_config[destination_name]
destination_type = configuration['type']
if destination_type == "redshift"
DataDuck.destinations[destination_name] = DataDuck::RedshiftDestination.new(destination_name, configuration)
else
raise ArgumentError.new("Unknown type '#{ destination_type }' for destination #{ destination_name }.")
end
end
end
|
.only_destination ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/dataduck/destination.rb', line 53
def self.only_destination
if DataDuck.destinations.keys.length != 1
raise ArgumentError.new("Must be exactly 1 destination.")
end
destination_name = DataDuck.destinations.keys[0]
return DataDuck::Destination.destination(destination_name)
end
|
Instance Method Details
#load_table!(table) ⇒ Object
29
30
31
|
# File 'lib/dataduck/destination.rb', line 29
def load_table!(table)
raise "Must implement load_table! in subclass"
end
|
#postprocess!(table) ⇒ Object
37
38
39
|
# File 'lib/dataduck/destination.rb', line 37
def postprocess!(table)
end
|
#recreate_table!(table) ⇒ Object
33
34
35
|
# File 'lib/dataduck/destination.rb', line 33
def recreate_table!(table)
raise "Must implement recreate_table! in subclass"
end
|