Class: ConsoleKit::Connections::SqlConnectionHandler
Overview
Instance Attribute Summary
#context
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, registry, #safe_diagnostics
clock_time, error_diagnostics, timeout_diagnostics
Class Method Details
.base_class_name ⇒ Object
16
|
# File 'lib/console_kit/connections/sql_connection_handler.rb', line 16
def base_class_name = ConsoleKit.configuration.sql_base_class
|
.sql_version(conn) ⇒ Object
10
11
12
13
14
|
# File 'lib/console_kit/connections/sql_connection_handler.rb', line 10
def sql_version(conn)
conn.select_value('SELECT version()')
rescue StandardError
nil
end
|
Instance Method Details
#available? ⇒ Boolean
26
|
# File 'lib/console_kit/connections/sql_connection_handler.rb', line 26
def available? = self.class.base_class_name.to_s.safe_constantize.present?
|
#connect ⇒ Object
19
20
21
22
23
24
|
# File 'lib/console_kit/connections/sql_connection_handler.rb', line 19
def connect
shard = context_attribute(:tenant_shard).presence&.to_sym
Output.print_info("#{connection_message(shard)} via #{base_class}")
disconnect_existing_pool
shard ? base_class.establish_connection(shard) : base_class.establish_connection
end
|
#diagnostics ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/console_kit/connections/sql_connection_handler.rb', line 28
def diagnostics
return unavailable_diagnostics('SQL') unless available?
perform_diagnostics
rescue StandardError => e
error_diagnostics('SQL', e)
end
|