Sha256: 6d40cb46b5e17872b3f48d8a306a507e8ad8af8a012b0831da13761f0980d250

Contents?: true

Size: 717 Bytes

Versions: 13

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

require 'active_record'

require 'active_record/connection_adapters/abstract/connection_pool'
require 'active_record/connection_adapters/postgresql_adapter'

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

      yield adapter.raw_connection
    end

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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
table_saw-3.1.0 lib/table_saw/connection.rb
table_saw-3.0.0 lib/table_saw/connection.rb
table_saw-2.10.0 lib/table_saw/connection.rb
table_saw-2.9.0 lib/table_saw/connection.rb
table_saw-2.8.1 lib/table_saw/connection.rb
table_saw-2.8.0 lib/table_saw/connection.rb
table_saw-2.7.0 lib/table_saw/connection.rb
table_saw-2.6.0 lib/table_saw/connection.rb
table_saw-2.5.0 lib/table_saw/connection.rb
table_saw-2.4.3 lib/table_saw/connection.rb
table_saw-2.4.2 lib/table_saw/connection.rb
table_saw-2.4.1 lib/table_saw/connection.rb
table_saw-2.4.0 lib/table_saw/connection.rb