Module: Mongoo

Defined in:
lib/mongoo.rb,
lib/mongoo/base.rb,
lib/mongoo/async.rb,
lib/mongoo/async.rb,
lib/mongoo/async.rb,
lib/mongoo/cursor.rb,
lib/mongoo/hash_ext.rb,
lib/mongoo/changelog.rb,
lib/mongoo/modifiers.rb,
lib/mongoo/mongohash.rb,
lib/mongoo/persistence.rb,
lib/mongoo/identity_map.rb,
lib/mongoo/attribute_proxy.rb,
lib/mongoo/attribute_sanitizer.rb

Defined Under Namespace

Modules: Changelog, HashExt, Modifiers, Persistence Classes: AlreadyInsertedError, AttributeProxy, AttributeSanitizer, Base, ConnNotSet, Cursor, DbNameNotSet, FakeMutex, IdentityMap, InsertError, InvalidAttributeValue, ModifierBuilder, ModifierUpdateError, Mongohash, NotInsertedError, NotValidError, RemoveError, StaleUpdateError, UnknownAttributeError, UpdateError

Constant Summary collapse

INDEX_META =
{}
ATTRIBUTE_META =
{}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.conn_optsObject

Returns the value of attribute conn_opts.



6
7
8
# File 'lib/mongoo.rb', line 6

def conn_opts
  @conn_opts
end

.db_nameObject

Returns the value of attribute db_name.



6
7
8
# File 'lib/mongoo.rb', line 6

def db_name
  @db_name
end

.verbose_debugObject

Returns the value of attribute verbose_debug.



6
7
8
# File 'lib/mongoo.rb', line 6

def verbose_debug
  @verbose_debug
end

Class Method Details

.connObject



8
9
10
11
# File 'lib/mongoo.rb', line 8

def conn
  Thread.current[:mongoo] ||= {}
  Thread.current[:mongoo][:conn] ||= Mongo::Connection.new(*conn_opts)
end

.dbObject



13
14
15
16
# File 'lib/mongoo.rb', line 13

def db
  Thread.current[:mongoo] ||= {}
  Thread.current[:mongoo][:db] ||= conn.db(db_name)
end

.modeObject



28
29
30
# File 'lib/mongoo.rb', line 28

def mode
  :sync
end

.reset_connection!Object



18
19
20
21
22
23
24
25
26
# File 'lib/mongoo.rb', line 18

def reset_connection!
  if Thread.current[:mongoo]
    Thread.current[:mongoo][:db] = nil
    if Thread.current[:mongoo][:conn]
      Thread.current[:mongoo][:conn].close
      Thread.current[:mongoo][:conn] = nil
    end
  end; true
end

.suppress_warningsObject



5
6
7
8
9
10
11
# File 'lib/mongoo/async.rb', line 5

def self.suppress_warnings
  original_verbosity = $VERBOSE
  $VERBOSE = nil
  result = yield
  $VERBOSE = original_verbosity
  return result
end