Module: DatabasePatcher::DB

Extended by:
DB
Included in:
DB
Defined in:
lib/database_patcher/db.rb

Instance Method Summary collapse

Instance Method Details

#create_connectionObject



8
9
10
11
12
# File 'lib/database_patcher/db.rb', line 8

def create_connection
  new_connection = Sequel.connect(DatabasePatcher::Environment.database_url)
  new_connection.loggers << new_logger
  new_connection
end

#new_loggerObject



14
15
16
17
18
# File 'lib/database_patcher/db.rb', line 14

def new_logger
  logger = Logger.new($stdout)
  logger.level = Logger::Severity::UNKNOWN
  logger
end

#valid_connection?(connection) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/database_patcher/db.rb', line 20

def valid_connection?(connection)
  !connection.nil? && connection.test_connection
rescue
  false
end