Sha256: 1a1164ffc60ed93c3bb951efbf0f32a96763c8532330da164fa77c7578342209

Contents?: true

Size: 1.35 KB

Versions: 25

Compression:

Stored size: 1.35 KB

Contents

require 'erb'
require 'yaml'

require 'rubypitaya/core/setup'

module RubyPitaya

  class DatabaseConfig

    def initialize(setup)
      @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'],
      }

      environment_name = setup.fetch('rubypitaya.server.environment', 'development')

      @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

25 entries across 21 versions & 1 rubygems

Version Path
rubypitaya-3.16.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.15.3 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.15.2 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.15.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.15.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.14.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.13.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.13.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.5 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.4 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.3 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.2 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.1 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.12.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.11.0 ./lib/rubypitaya/core/database_config.rb
rubypitaya-3.10.0 ./lib/rubypitaya/core/database_config.rb