Sha256: fa2f2ca9a29777713b896ac8538502928849189a989149f32ba58836a1fc80e0

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

# frozen_string_literal: true

require 'pg'
require 'active_record'
require 'active_record/connection_adapters/postgresql_adapter'

module TableSaw
  module Connection
    def self.with
      raise ArgumentError, 'requires a block' unless block_given?

      yield raw
    end

    def self.raw
      @raw ||= PG::Connection.new(TableSaw.configuration.connection)
    end

    def self.exec(sql)
      TableSaw::Connection.with do |conn|
        conn.exec(sql)
      end
    end

    def self.adapter
      @adapter ||=
        ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.new(nil, nil, TableSaw.configuration.connection, {})
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
table_saw-2.3.0 lib/table_saw/connection.rb
table_saw-2.2.0 lib/table_saw/connection.rb