Module: UpdateValuesAll::BatchUpdate

Defined in:
lib/update_values_all/batch_update.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



8
9
10
11
12
# File 'lib/update_values_all/batch_update.rb', line 8

def self.extended(klass)
  if defined?(::PG::Connection)
    klass.extend(UpdateValuesAll::Adapters::Postgres)
  end
end

Instance Method Details

#update_values_all(data, **keyword_args) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/update_values_all/batch_update.rb', line 14

def update_values_all(data, **keyword_args)
  return [] if data.empty?

  keyword_args[:key_to_match] ||= primary_key

  if defined?(::PG::Connection) && connection.raw_connection.is_a?(::PG::Connection)
    pg_update_values_all(data, **keyword_args)
  end
end