Class: TaliaUtil::Configuration::DatabaseConfig
- Inherits:
-
ConfigFile
- Object
- ConfigFile
- TaliaUtil::Configuration::DatabaseConfig
- Defined in:
- lib/talia_util/configuration/database_config.rb
Overview
This contains some special methods for database config files
Instance Method Summary collapse
-
#initialize(template) ⇒ DatabaseConfig
constructor
A new instance of DatabaseConfig.
-
#set_adapter(db_adapter) ⇒ Object
Sets the database adapter for all environments.
-
#set_credentials(db_user, db_pass) ⇒ Object
Set the credentials for all environments.
-
#set_database_names(app_name) ⇒ Object
Sets the database names based on the given application name.
-
#set_socket(socket) ⇒ Object
Sets the socket file for the db.
Methods inherited from ConfigFile
Constructor Details
#initialize(template) ⇒ DatabaseConfig
Returns a new instance of DatabaseConfig.
9 10 11 12 |
# File 'lib/talia_util/configuration/database_config.rb', line 9 def initialize(template) @environments = ['test', 'development', 'production'] super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class TaliaUtil::Configuration::ConfigFile
Instance Method Details
#set_adapter(db_adapter) ⇒ Object
Sets the database adapter for all environments
23 24 25 |
# File 'lib/talia_util/configuration/database_config.rb', line 23 def set_adapter(db_adapter) @environments.each { |env| @config_doc[env]['adapter'] = db_adapter } end |
#set_credentials(db_user, db_pass) ⇒ Object
Set the credentials for all environments
15 16 17 18 19 20 |
# File 'lib/talia_util/configuration/database_config.rb', line 15 def set_credentials(db_user, db_pass) @environments.each do |env| @config_doc[env]['username'] = db_user @config_doc[env]['password'] = db_pass end end |
#set_database_names(app_name) ⇒ Object
Sets the database names based on the given application name
28 29 30 |
# File 'lib/talia_util/configuration/database_config.rb', line 28 def set_database_names(app_name) @environments.each { |env| @config_doc[env]['database'] = "#{app_name}_#{env}" } end |
#set_socket(socket) ⇒ Object
Sets the socket file for the db
33 34 35 |
# File 'lib/talia_util/configuration/database_config.rb', line 33 def set_socket(socket) @environments.each { |env| @config_doc[env]['socket'] = socket } end |