Sha256: a098533eed2a1e1e48e6efe2bd77f6e7604077f0e94348e3c711b62881b29422

Contents?: true

Size: 565 Bytes

Versions: 7

Compression:

Stored size: 565 Bytes

Contents

module Octoshark
  class ConnectionManager
    include CurrentConnection

    def with_connection(config, connection_name: nil, &block)
      connection_method = "#{config[:adapter]}_connection"

      connection = ActiveRecord::Base.send(connection_method, config)
      connection.connection_name = connection_name
      connection.database_name = config[:database] if config[:database]

      begin
        change_connection_reference(connection) do
          yield(connection)
        end
      ensure
        connection.disconnect!
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
octoshark-0.5.1 lib/octoshark/connection_manager.rb
octoshark-0.5.0 lib/octoshark/connection_manager.rb
octoshark-0.4.0 lib/octoshark/connection_manager.rb
octoshark-0.3.0 lib/octoshark/connection_manager.rb
octoshark-0.2.2 lib/octoshark/connection_manager.rb
octoshark-0.2.1 lib/octoshark/connection_manager.rb
octoshark-0.2.0 lib/octoshark/connection_manager.rb