Sha256: 6afe848deb8133a2b8d537643d1f22d8bbe814717e68172e55d9a0468e2d354b

Contents?: true

Size: 609 Bytes

Versions: 7

Compression:

Stored size: 609 Bytes

Contents

module Adhoq
  class Executor
    class ConnectionWrapper
      attr_reader :connection

      def initialize
        @connection = Adhoq.config.callablize(:database_connection).call
      end

      def select(query)
        with_sandbox do
          connection.exec_query(query)
        end
      end

      def explain(query)
        with_sandbox do
          connection.explain(query)
        end
      end

      def with_sandbox
        result = nil
        connection.transaction do
          result = yield
          raise ActiveRecord::Rollback
        end
        result
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
adhoq-0.3.0 lib/adhoq/executor/connection_wrapper.rb
adhoq-0.2.0 lib/adhoq/executor/connection_wrapper.rb
adhoq-0.1.2 lib/adhoq/executor/connection_wrapper.rb
adhoq-0.1.1 lib/adhoq/executor/connection_wrapper.rb
adhoq-0.1.0 lib/adhoq/executor/connection_wrapper.rb
adhoq-0.0.7 lib/adhoq/executor/connection_wrapper.rb
adhoq-0.0.6 lib/adhoq/executor/connection_wrapper.rb