Module: Mongoid::Simplify::Connection

Included in:
Mongoid
Defined in:
lib/mongoid-simplify/connection.rb

Instance Method Summary collapse

Instance Method Details

#use(*args) ⇒ Object

In mongoid >= 3 the methods for connecting changed into something to complex and to complicated. So I reimplemented this way of connecting with an plain URI.

Examples:

set the default session

Mongoid.use("mongodb://localhost:27017/database")


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mongoid-simplify/connection.rb', line 10

def use(*args)
	args.flatten.each do |arg|
		if arg.kind_of? String
			use_session(:default, arg)
		elsif arg.kind_of? Hash
			arg.each do |name, uri|
				use_session(name.to_sym, uri)
			end
		end
	end
end