Sha256: d3e52a64e2ed83b5d426f17e0d7840e3a3f24b0bd5c254b08694c3448be01061

Contents?: true

Size: 1.14 KB

Versions: 28

Compression:

Stored size: 1.14 KB

Contents

require File.dirname(__FILE__) + '/config_file'

module TaliaUtil
  module Configuration
    
    # This contains some special methods for database config files
    class DatabaseConfig < ConfigFile
      
      def initialize(template)
        @environments = ['test', 'development', 'production']
        super
      end
      
      # Set the credentials for all environments
      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
      
      # Sets the database adapter for all environments
      def set_adapter(db_adapter)
        @environments.each { |env| @config_doc[env]['adapter'] = db_adapter }
      end
      
      # Sets the database names based on the given application name
      def set_database_names(app_name)
        @environments.each { |env| @config_doc[env]['database'] = "#{app_name}_#{env}" }
      end
      
      # Sets the socket file for the db
      def set_socket(socket)
        @environments.each { |env| @config_doc[env]['socket'] = socket  }
      end
      
    end
    
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
talia_core-0.7.0 lib/talia_util/configuration/database_config.rb
talia_core-0.5.4 lib/talia_util/configuration/database_config.rb
talia_core-0.5.3 lib/talia_util/configuration/database_config.rb
talia_core-0.5.2 lib/talia_util/configuration/database_config.rb
talia_core-0.5.1 lib/talia_util/configuration/database_config.rb
talia_core-0.5.0 lib/talia_util/configuration/database_config.rb
talia_core-0.4.22 lib/talia_util/configuration/database_config.rb
talia_core-0.4.20 lib/talia_util/configuration/database_config.rb
talia_core-0.4.19 lib/talia_util/configuration/database_config.rb
talia_core-0.4.18 lib/talia_util/configuration/database_config.rb
talia_core-0.4.17 lib/talia_util/configuration/database_config.rb
talia_core-0.4.16 lib/talia_util/configuration/database_config.rb
talia_core-0.4.15 lib/talia_util/configuration/database_config.rb
talia_core-0.4.14 lib/talia_util/configuration/database_config.rb
talia_core-0.4.13 lib/talia_util/configuration/database_config.rb
talia_core-0.4.12 lib/talia_util/configuration/database_config.rb
talia_core-0.4.11 lib/talia_util/configuration/database_config.rb
talia_core-0.4.10 lib/talia_util/configuration/database_config.rb
talia_core-0.4.9 lib/talia_util/configuration/database_config.rb
talia_core-0.4.8 lib/talia_util/configuration/database_config.rb