Class: RubyPitaya::DatabaseConfig
- Inherits:
-
Object
- Object
- RubyPitaya::DatabaseConfig
- Defined in:
- lib/rubypitaya/core/database_config.rb
Instance Method Summary collapse
- #config ⇒ Object
- #connection_data ⇒ Object
- #connection_data_without_database ⇒ Object
- #database_name ⇒ Object
-
#initialize(environment_name, database_config_path) ⇒ DatabaseConfig
constructor
A new instance of DatabaseConfig.
- #migrations_path ⇒ Object
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
#config ⇒ Object
17 18 19 |
# File 'lib/rubypitaya/core/database_config.rb', line 17 def config @config[@environment_name] end |
#connection_data ⇒ Object
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_database ⇒ Object
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_name ⇒ Object
44 45 46 |
# File 'lib/rubypitaya/core/database_config.rb', line 44 def database_name config['database'] end |
#migrations_path ⇒ Object
48 49 50 |
# File 'lib/rubypitaya/core/database_config.rb', line 48 def migrations_path @migrations_path end |