Sha256: 7d7f1b8554cdc39dd43113fbaa49627e4a158848e0b831c6f417632f1a910054

Contents?: true

Size: 480 Bytes

Versions: 1

Compression:

Stored size: 480 Bytes

Contents

module Separatum
  module Exporters
    class ActiveRecord
      def call(*objects)
        ::ActiveRecord::Base.transaction do
          objects.each do |o|
            o.class.connection.execute("ALTER TABLE %s DISABLE TRIGGER ALL;" % [o.class.table_name])
            o.save!(validate: false)
            o.class.connection.execute("ALTER TABLE %s ENABLE TRIGGER ALL;" % [o.class.table_name])
          end
        end
        objects.map(&:reload)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
separatum-0.1.0 lib/separatum/exporters/active_record.rb