Sha256: dfcaffedf7619865c3674b14b18d064542f1ad51ed3f306c79b0f05feda800fe

Contents?: true

Size: 756 Bytes

Versions: 11

Compression:

Stored size: 756 Bytes

Contents

# Config lets a user set global config options for Volt.
class Volt

  def self.setup
    yield self.config
  end

  def self.config
    @config || self.reset_config!
  end

  # Resets the configuration to the default (empty hash)
  def self.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

  # Load in all .rb files in the config folder
  def self.run_files_in_config_folder
    Dir[Dir.pwd + '/config/*.rb'].each do |config_file|
      require(config_file)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
volt-0.8.14 lib/volt/config.rb
volt-0.8.13 lib/volt/config.rb
volt-0.8.11 lib/volt/config.rb
volt-0.8.10 lib/volt/config.rb
volt-0.8.9 lib/volt/config.rb
volt-0.8.8 lib/volt/config.rb
volt-0.8.7 lib/volt/config.rb
volt-0.8.6 lib/volt/config.rb
volt-0.8.5 lib/volt/config.rb
volt-0.8.4 lib/volt/config.rb
volt-0.8.3 lib/volt/config.rb