Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 18 lines (18 sloc) 0.579 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
if ENV['VCAP_SERVICES']
  services = JSON.parse(ENV['VCAP_SERVICES'])
  if services
    mongodb_service = nil
    services.each do |k, v|
      v.each do |s|
        if k.split('-')[0].downcase == 'mongodb'
          mongodb_service = s["credentials"]
        end
      end
    end
    if mongodb_service
      MongoMapper.connection = Mongo::Connection.new(mongodb_service['hostname'], mongodb_service['port'])
      MongoMapper.database = mongodb_service['db']
      MongoMapper.database.authenticate(mongodb_service['username'], mongodb_service['password'])
    end
  end
end
Something went wrong with that request. Please try again.