Module: GemStats::Connection
- Defined in:
- lib/gem_stats/connection.rb
Class Method Summary collapse
- .connect(options = {}) ⇒ Object
- .get_config(*path) {|YAML::load(ERB.new(File.read File.join(path)).result)| ... } ⇒ Object
Class Method Details
.connect(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/gem_stats/connection.rb', line 5 def self.connect( = {}) if .empty? env, path = defined?(Rails)? [Rails.env, [Rails.root, 'config/database.yml']] : [ENV['ENV'] || 'development', File.('../../../config/database.yml', __FILE__)] get_config(path) {|config| MongoMapper.setup(config, env) } else MongoMapper.setup([:config], [:env]) end end |
.get_config(*path) {|YAML::load(ERB.new(File.read File.join(path)).result)| ... } ⇒ Object
15 16 17 |
# File 'lib/gem_stats/connection.rb', line 15 def self.get_config(*path) yield YAML::load(ERB.new(File.read File.join(path)).result) end |