Class: Rooq::DefaultConnectionProvider

Inherits:
ConnectionProvider show all
Defined in:
lib/rooq/connection.rb

Overview

A connection provider that wraps a single connection. The connection lifecycle is managed externally by the caller. Release is a no-op - the connection stays open until closed externally.

Use this when you want to control transactions and connection lifecycle yourself.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ConnectionProvider

#with_connection

Constructor Details

#initialize(connection) ⇒ DefaultConnectionProvider

Returns a new instance of DefaultConnectionProvider.

Parameters:

  • connection (Object)

    the connection to wrap



46
47
48
49
# File 'lib/rooq/connection.rb', line 46

def initialize(connection)
  super()
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



43
44
45
# File 'lib/rooq/connection.rb', line 43

def connection
  @connection
end

Instance Method Details

#acquireObject

Always returns the same connection instance.

Returns:

  • (Object)

    the wrapped connection



53
54
55
# File 'lib/rooq/connection.rb', line 53

def acquire
  @connection
end

#release(connection) ⇒ Object

No-op - the connection lifecycle is managed externally.

Parameters:

  • connection (Object)

    the connection (ignored)



59
60
61
# File 'lib/rooq/connection.rb', line 59

def release(connection)
  # No-op: connection lifecycle is managed externally
end