Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/mongo_adapter.rb

Class Method Summary collapse

Class Method Details

.mongo_connection(config) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_record/connection_adapters/mongo_adapter.rb', line 9

def self.mongo_connection(config)
  config = config.symbolize_keys
  pair_or_host = config[:host] || 'localhost'
  port = config[:port] || 27017
  database = config[:database]

  options = config.dup
  [:adapter, :host, :port, :database].each {|i| options.delete(i) }

  connection = Mongo::Connection.new(pair_or_host, port, options).db(database)
  ConnectionAdapters::MongoAdapter.new(connection, logger, config)
end