Sha256: 2996ee46cfb114c386b6c93035acb87c0853a7cc13ec4cb95bc63588c534cb58

Contents?: true

Size: 402 Bytes

Versions: 3

Compression:

Stored size: 402 Bytes

Contents

# frozen_string_literal: true

require 'pg'

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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
table_saw-2.1.0 lib/table_saw/connection.rb
table_saw-2.0.0 lib/table_saw/connection.rb
table_saw-1.3.0 lib/table_saw/connection.rb