Class: RubyPitaya::DatabaseConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/core/database_config.rb

Instance Method Summary collapse

Constructor Details

#initialize(environment_name, database_config_path) ⇒ DatabaseConfig

Returns a new instance of DatabaseConfig.



10
11
12
13
14
15
# File 'lib/rubypitaya/core/database_config.rb', line 10

def initialize(environment_name, database_config_path)
  @environment_name = environment_name

  yaml_contents = File.open(database_config_path).read
  @config = YAML.load( ERB.new(yaml_contents).result )
end

Instance Method Details

#configObject



17
18
19
# File 'lib/rubypitaya/core/database_config.rb', line 17

def config
  @config[@environment_name]
end

#connection_dataObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rubypitaya/core/database_config.rb', line 21

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

#connection_data_without_databaseObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/rubypitaya/core/database_config.rb', line 33

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

#database_nameObject



44
45
46
# File 'lib/rubypitaya/core/database_config.rb', line 44

def database_name
  config['database']
end

#migrations_pathObject



48
49
50
# File 'lib/rubypitaya/core/database_config.rb', line 48

def migrations_path
  @migrations_path
end