Class: Bootstrap::Db::Config
- Inherits:
-
Object
- Object
- Bootstrap::Db::Config
- Defined in:
- lib/bootstrap/db/config.rb
Constant Summary collapse
- DB_CONFIG_PATH =
'config/database.yml'
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#bootstrap_dir ⇒ Object
Returns the value of attribute bootstrap_dir.
-
#settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(loaded_settings) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(loaded_settings) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 |
# File 'lib/bootstrap/db/config.rb', line 8 def initialize(loaded_settings) self.settings = loaded_settings[Rails.env] self.adapter = self.settings["adapter"].to_sym self.bootstrap_dir = ENV['BOOTSTRAP_DIR'] || default_directory ensure_bootstrap_dir_exists! end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
6 7 8 |
# File 'lib/bootstrap/db/config.rb', line 6 def adapter @adapter end |
#bootstrap_dir ⇒ Object
Returns the value of attribute bootstrap_dir.
6 7 8 |
# File 'lib/bootstrap/db/config.rb', line 6 def bootstrap_dir @bootstrap_dir end |
#settings ⇒ Object
Returns the value of attribute settings.
6 7 8 |
# File 'lib/bootstrap/db/config.rb', line 6 def settings @settings end |
Class Method Details
.load!(configuration_path = File.join(Rails.root, DB_CONFIG_PATH)) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bootstrap/db/config.rb', line 17 def self.load!(configuration_path = File.join(Rails.root, DB_CONFIG_PATH)) unless File.exists?(configuration_path) raise "Error - Please ensure your '#{File.basename(configuration_path)}' exists" end config = YAML::load(ERB.new(IO.read(configuration_path)).result) unless config[Rails.env]["host"] raise "Please ensure your '#{File.basename(configuration_path)}' file has a host for the database. eg. host = localhost" end new(config) end |