Module: Tsuga::Adapter::ActiveRecord::Base::DatasetMethods

Defined in:
lib/tsuga/adapter/active_record/base.rb

Instance Method Summary collapse

Instance Method Details

#collect_idsObject



38
39
40
# File 'lib/tsuga/adapter/active_record/base.rb', line 38

def collect_ids
  pluck(:id)
end

#mass_create(new_records) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/tsuga/adapter/active_record/base.rb', line 21

def mass_create(new_records)
  return if new_records.empty?

  # Old SQLite versions (like on Travis) do not support bulk inserts
  if connection.class.name !~ /sqlite/i || connection.send(:sqlite_version) >= '3.7.11'
    _bulk_insert(new_records)
  else
    new_records.each(&:save!)
  end
end

#mass_update(records) ⇒ Object



32
33
34
35
36
# File 'lib/tsuga/adapter/active_record/base.rb', line 32

def mass_update(records)
  transaction do
    records.each(&:save!)
  end
end