Module: Volt::Config
- Included in:
- Volt
- Defined in:
- lib/volt/config.rb
Instance Method Summary collapse
- #config ⇒ Object
-
#reset_config! ⇒ Object
Resets the configuration to the default (empty hash).
-
#run_files_in_config_folder ⇒ Object
Load in all .rb files in the config folder.
- #setup {|config| ... } ⇒ Object
Instance Method Details
#config ⇒ Object
8 9 10 |
# File 'lib/volt/config.rb', line 8 def config @config || self.reset_config! end |
#reset_config! ⇒ Object
Resets the configuration to the default (empty hash)
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/volt/config.rb', line 13 def reset_config! app_name = File.basename(Dir.pwd) @config = OpenStruct.new( app_name: app_name, db_name: ENV['DB_NAME'] || (app_name + '_' + Volt.env.to_s), db_host: ENV['DB_HOST'] || 'localhost', db_port: (ENV['DB_PORT'] || 27_017).to_i, db_driver: ENV['DB_DRIVER'] || 'mongo' ) end |
#run_files_in_config_folder ⇒ Object
Load in all .rb files in the config folder
26 27 28 29 30 |
# File 'lib/volt/config.rb', line 26 def run_files_in_config_folder Dir[Dir.pwd + '/config/*.rb'].each do |config_file| require(config_file) end end |
#setup {|config| ... } ⇒ Object
4 5 6 |
# File 'lib/volt/config.rb', line 4 def setup yield config end |