module AppConfigRails
Constants
- VERSION
Public Class Methods
load_app_config!()
click to toggle source
# File lib/app_config_rails.rb, line 6 def self.load_app_config! case db_config[:adapter] when 'mysql' configure_mysql when 'postgresql' configure_postgres when 'sqlite3' configure_sqlite else raise RuntimeError, "AppConfigRails: Database adapter '#{db_config[:adapter]}' not supported; please create an issue if you would like it implemented." end end
Private Class Methods
configure_mysql()
click to toggle source
TODO: Finish this once AppConfig supports MySQL.
# File lib/app_config_rails.rb, line 26 def self.configure_mysql raise RuntimeError, 'AppConfigRails: MySQL support not yet implemented.' end
configure_postgres()
click to toggle source
# File lib/app_config_rails.rb, line 30 def self.configure_postgres postgres = { host: db_config[:host], dbname: db_config[:database], table: 'app_config' } postgres[:port] = db_config[:port] if db_config[:port] postgres[:user] = db_config[:username] if db_config[:username] postgres[:password] = db_config[:password] if db_config[:password] # Catch PG::Error in case the app_config table (migration) hasn't been created. begin AppConfig.setup!(postgres: postgres) rescue ::PG::Error => e Rails.logger.warn "WARN: AppConfig table '#{postgres[:table]}' does not exist; migration has not been run." end end
configure_sqlite()
click to toggle source
TODO: Finish this once AppConfig supports SQLite.
# File lib/app_config_rails.rb, line 51 def self.configure_sqlite raise RuntimeError, 'AppConfigRails: SQLite support not yet implemented.' end
db_config()
click to toggle source
# File lib/app_config_rails.rb, line 21 def self.db_config @@__db_config ||= ActiveRecord::Base.connection_config end