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 {|self.config| ... } ⇒ Object
Instance Method Details
#config ⇒ Object
9 10 11 |
# File 'lib/volt/config.rb', line 9 def config @config || self.reset_config! end |
#reset_config! ⇒ Object
Resets the configuration to the default (empty hash)
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/volt/config.rb', line 14 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'] || 27017).to_i, db_driver: ENV['DB_DRIVER'] || 'mongo' ) end |
#run_files_in_config_folder ⇒ Object
Load in all .rb files in the config folder
27 28 29 30 31 |
# File 'lib/volt/config.rb', line 27 def run_files_in_config_folder Dir[Dir.pwd + '/config/*.rb'].each do |config_file| require(config_file) end end |
#setup {|self.config| ... } ⇒ Object
5 6 7 |
# File 'lib/volt/config.rb', line 5 def setup yield self.config end |