Class: Mongo::Sugar::Connection::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/mongo-sugar/connection/config.rb

Overview

Config file reader

Instance Method Summary collapse

Constructor Details

#initialize(config = ENV['MONGODB_CONFIG'], environment = ENV['RACK_ENV']) ⇒ Config

Returns a new instance of Config.



13
14
15
16
# File 'lib/mongo-sugar/connection/config.rb', line 13

def initialize(config=ENV['MONGODB_CONFIG'], environment=ENV['RACK_ENV'])
  config ||= 'config/mongo.yml'
  @config = (File.exists?(config)) ? YAML.load_file(config)[environment] : {}
end

Instance Method Details

#get(name) ⇒ String

Retrieve a configuration key

Parameters:

  • key (String)

Returns:

  • (String)

    database uri



21
22
23
# File 'lib/mongo-sugar/connection/config.rb', line 21

def get(name)
  @config[name]
end