Class: Mongo::Sugar::Connection::Config
- Inherits:
-
Object
- Object
- Mongo::Sugar::Connection::Config
- Includes:
- Singleton
- Defined in:
- lib/mongo-sugar/connection/config.rb
Overview
Config file reader
Instance Method Summary collapse
-
#get(name) ⇒ String
Retrieve a configuration key.
-
#initialize(config = ENV['MONGODB_CONFIG'], environment = ENV['RACK_ENV']) ⇒ Config
constructor
A new instance of Config.
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
21 22 23 |
# File 'lib/mongo-sugar/connection/config.rb', line 21 def get(name) @config[name] end |