Class: ActiveRecordDataLoader::CopyStrategy
- Inherits:
-
Object
- Object
- ActiveRecordDataLoader::CopyStrategy
- Defined in:
- lib/active_record_data_loader/copy_strategy.rb
Instance Method Summary collapse
-
#initialize(data_generator, file_adapter) ⇒ CopyStrategy
constructor
A new instance of CopyStrategy.
- #load_batch(row_numbers, connection) ⇒ Object
- #name ⇒ Object
- #table_name ⇒ Object
Constructor Details
#initialize(data_generator, file_adapter) ⇒ CopyStrategy
Returns a new instance of CopyStrategy.
5 6 7 8 |
# File 'lib/active_record_data_loader/copy_strategy.rb', line 5 def initialize(data_generator, file_adapter) @data_generator = data_generator @file_adapter = file_adapter end |
Instance Method Details
#load_batch(row_numbers, connection) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_record_data_loader/copy_strategy.rb', line 10 def load_batch(row_numbers, connection) data = csv_rows(row_numbers, connection) copy( connection: connection, table: table_name_for_copy(connection), columns: columns_for_copy(connection), data: data, row_numbers: row_numbers ) file_adapter.copy( table: table_name_for_copy(connection), columns: columns_for_copy(connection), data: data, row_numbers: row_numbers ) end |
#name ⇒ Object
31 32 33 |
# File 'lib/active_record_data_loader/copy_strategy.rb', line 31 def name "COPY" end |
#table_name ⇒ Object
27 28 29 |
# File 'lib/active_record_data_loader/copy_strategy.rb', line 27 def table_name data_generator.table end |