Class: StagingTable::Adapters::Base
- Inherits:
-
Object
- Object
- StagingTable::Adapters::Base
show all
- Defined in:
- lib/staging_table/adapters/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(connection) ⇒ Base
Returns a new instance of Base.
8
9
10
|
# File 'lib/staging_table/adapters/base.rb', line 8
def initialize(connection)
@connection = connection
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
6
7
8
|
# File 'lib/staging_table/adapters/base.rb', line 6
def connection
@connection
end
|
Class Method Details
.for(connection) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/staging_table/adapters/base.rb', line 21
def self.for(connection)
adapter_name = connection.adapter_name.downcase
case adapter_name
when /postgresql/
Postgresql.new(connection)
when /mysql/
Mysql.new(connection)
when /sqlite/
Sqlite.new(connection)
else
raise AdapterError, "Unsupported adapter: #{adapter_name}. StagingTable supports PostgreSQL, MySQL, and SQLite adapters."
end
end
|
Instance Method Details
#create_table(temp_table_name, source_table_name, options = {}) ⇒ Object
12
13
14
|
# File 'lib/staging_table/adapters/base.rb', line 12
def create_table(temp_table_name, source_table_name, options = {})
raise NotImplementedError
end
|
#drop_table(temp_table_name) ⇒ Object
16
17
18
19
|
# File 'lib/staging_table/adapters/base.rb', line 16
def drop_table(temp_table_name)
quoted_table = connection.quote_table_name(temp_table_name)
connection.execute("DROP TABLE IF EXISTS #{quoted_table}")
end
|