Module: MongoMapper::Plugins::Persistence::ClassMethods

Defined in:
lib/mongo_mapper/plugins/persistence.rb

Defined Under Namespace

Classes: Unsupported

Instance Method Summary collapse

Instance Method Details

#collectionObject



46
47
48
49
# File 'lib/mongo_mapper/plugins/persistence.rb', line 46

def collection
  not_supported_by_embedded
  database.collection(collection_name)
end

#collection_nameObject



41
42
43
44
# File 'lib/mongo_mapper/plugins/persistence.rb', line 41

def collection_name
  not_supported_by_embedded
  @collection_name ||= self.to_s.tableize.gsub(/\//, '.')
end

#connection(mongo_connection = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/mongo_mapper/plugins/persistence.rb', line 7

def connection(mongo_connection=nil)
  not_supported_by_embedded
  if mongo_connection.nil?
    @connection ||= MongoMapper.connection
  else
    @connection = mongo_connection
  end
  @connection
end

#databaseObject



27
28
29
30
31
32
33
34
# File 'lib/mongo_mapper/plugins/persistence.rb', line 27

def database
  not_supported_by_embedded
  if database_name.nil?
    MongoMapper.database
  else
    connection.db(database_name)
  end
end

#database_nameObject



22
23
24
25
# File 'lib/mongo_mapper/plugins/persistence.rb', line 22

def database_name
  not_supported_by_embedded
  @database_name
end

#set_collection_name(name) ⇒ Object



36
37
38
39
# File 'lib/mongo_mapper/plugins/persistence.rb', line 36

def set_collection_name(name)
  not_supported_by_embedded
  @collection_name = name
end

#set_database_name(name) ⇒ Object



17
18
19
20
# File 'lib/mongo_mapper/plugins/persistence.rb', line 17

def set_database_name(name)
  not_supported_by_embedded
  @database_name = name
end