Sha256: 214982a95345627ab2e4da6210e2d246f70baf8e16ccfc0454244443c420f225

Contents?: true

Size: 1.29 KB

Versions: 31

Compression:

Stored size: 1.29 KB

Contents

require 'erb'
require 'yaml'

require 'rubypitaya/core/setup'

module RubyPitaya

  class DatabaseConfig

    def initialize()
      @setup = Setup.new

      @config = {
        'adapter' => 'postgresql',
        'encoding' => 'unicode',
        'pool' => @setup.fetch('rubypitaya.database.pool', 5),
        'host' => @setup['rubypitaya.database.host'],
        'user' => @setup['rubypitaya.database.user'],
        'password' => @setup['rubypitaya.database.password'],
        'database' => @setup['rubypitaya.database.name'],
      }

      @config['database'] = "#{@config['database']}_test" if @environment_name == 'test'
    end

    def config
      @config
    end

    def connection_data
      {
        'adapter': config['adapter'],
        'encoding': config['encoding'],
        'pool': config['pool'],
        'host': config['host'],
        'user': config['user'],
        'password': config['password'],
        'database': config['database'],
      }
    end

    def connection_data_without_database
      {
        'adapter': config['adapter'],
        'encoding': config['encoding'],
        'pool': config['pool'],
        'host': config['host'],
        'user': config['user'],
        'password': config['password'],
      }
    end

    def database_name
      config['database']
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
rubypitaya-3.5.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.4.2 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.4.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.4.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.3.7 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.3.6 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.3.5 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.3.4 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.3.3 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.3.2 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.3.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.3.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.2.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.1.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.1.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.0.3 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.0.2 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.0.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.0.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-2.27.1 ./lib/rubypitaya/core/database_config.rb