Class: PostgresUpsert::Writer
- Inherits:
-
Object
- Object
- PostgresUpsert::Writer
- Defined in:
- lib/postgres_upsert/writer.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(klass, destination, source, options = {}) ⇒ Writer
constructor
A new instance of Writer.
- #write ⇒ Object
Constructor Details
#initialize(klass, destination, source, options = {}) ⇒ Writer
Returns a new instance of Writer.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/postgres_upsert/writer.rb', line 4 def initialize(klass, destination, source, = {}) @klass = klass @destination = destination @source = source = .reverse_merge({ delimiter: ',', header: true, unique_key: [primary_key], update_only: false }) @source = source [:unique_key] = Array.wrap([:unique_key]) end |
Instance Method Details
#write ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/postgres_upsert/writer.rb', line 19 def write create_temp_table if @source.continuous_write_enabled write_continuous else write_batched end upsert_from_temp_table drop_temp_table summarize_results end |