Sha256: 00c4dc2bb50c348f48b918dc1eadb1afa8173dc4ae2a79c289c2f1130857cbd3
Contents?: true
Size: 846 Bytes
Versions: 2
Compression:
Stored size: 846 Bytes
Contents
module EasyReports class DatabaseMediator class DatabaseNotFoundError < StandardError; end attr_reader :db, :db_config delegate :adapter, :username, :password, :host, :port, :database_name, to: :db_config def initialize @db_config = load_database_config @db = establish_connection rescue => e Rails.logger.info "#{e.message}" raise DatabaseNotFoundError end def tables db.tables end private def load_database_config EasyReports::DatabaseConfig.find(params[:db_id]) end def establish_connection ::Sequel.connect( "#{adapter}://#{username}:#{password}@#{host}:#{port}/#{database_name}", :max_connections => db_config.pool, :logger => Logger.new('log/db.log')) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
easy_reports-0.0.25 | app/services/easy_reports/database_mediator.rb |
easy_reports-0.0.24 | app/services/easy_reports/database_mediator.rb |