Class: Sequel::ConnectionGuard::ConnectionGuard Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel/extensions/connection_guard/connection_guard.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(config, &initializer) ⇒ ConnectionGuard

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ConnectionGuard.

Parameters:

  • config (String, Hash)

    database configuration

  • initializer (Proc)

    code to run upon successful connection

Since:

  • 0.1.0



13
14
15
16
17
18
19
# File 'lib/sequel/extensions/connection_guard/connection_guard.rb', line 13

def initialize(config, &initializer)
  @config = config
  @initializer = initializer
  @connection = nil

  try_establish_connection
end

Instance Method Details

#force_execute {|@connection| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yields:

  • (@connection)

Raises:

  • (Sequel::DatabaseConnectionError)

    connection failure

Since:

  • 0.1.0



25
26
27
28
29
30
# File 'lib/sequel/extensions/connection_guard/connection_guard.rb', line 25

def force_execute(&_block)
  try_establish_connection if @connection.nil?
  raise Sequel::DatabaseConnectionError unless connection_established?

  yield @connection
end

#raw_handleObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (Sequel::DatabaseConnectionError)

    if connection is not established

Since:

  • 0.1.0



36
37
38
39
40
41
# File 'lib/sequel/extensions/connection_guard/connection_guard.rb', line 36

def raw_handle
  try_establish_connection if @connection.nil?

  return @connection if connection_established?
  raise Sequel::DatabaseConnectionError
end