module Redshift::Client::ConnectionHandling
Public Instance Methods
connected?()
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 32 def connected? !! current[:connection] end
connection()
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 14 def connection return current[:connection] if connected? ActiveSupport.run_load_hooks :redshift_client_connection check_established! current[:connection] = Connection.new(current[:configuration]) current[:connection] end
disconnect()
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 24 def disconnect clear_connection! end
establish_connection(config = {})
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 7 def establish_connection(config = {}) clear_connection! clear_thread! current[:configuration] = Configuration.resolve(config) end
established?()
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 28 def established? !! current[:configuration] end
Private Instance Methods
check_established!()
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 37 def check_established! raise ConnectionNotEstablished.new unless established? end
clear_connection!()
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 41 def clear_connection! current[:connection] && current[:connection].close current[:connection] = nil end
clear_thread!()
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 46 def clear_thread! Thread.current[:redshift] = nil end
current()
click to toggle source
# File lib/redshift/client/connection_handling.rb, line 50 def current Thread.current[:redshift] ||= {} end