class PostgresUpsert::ReadAdapters::ActiveRecordAdapter
Public Class Methods
new(source, options)
click to toggle source
# File lib/postgres_upsert/read_adapters/active_record_adapter.rb, line 4 def initialize(source, options) @options = sanitize_options(options) @source = source end
Public Instance Methods
columns()
click to toggle source
# File lib/postgres_upsert/read_adapters/active_record_adapter.rb, line 32 def columns @source.column_names end
continuous_write_enabled()
click to toggle source
# File lib/postgres_upsert/read_adapters/active_record_adapter.rb, line 15 def continuous_write_enabled false end
gets() { |line| ... }
click to toggle source
# File lib/postgres_upsert/read_adapters/active_record_adapter.rb, line 19 def gets(&block) batch_size = 1_000 line = "" conn = @source.connection.raw_connection conn.copy_data("COPY #{@source.table_name} TO STDOUT") do while (line_read = conn.get_copy_data) do line << line_read end end yield line end
sanitize_options(options)
click to toggle source
# File lib/postgres_upsert/read_adapters/active_record_adapter.rb, line 9 def sanitize_options(options) options.slice( :columns, :map, :unique_key ) end