Module: Mongoid::Collections::ClassMethods

Defined in:
lib/mongoid/collections.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#collectionObject

Returns the collection associated with this Document. If the document is embedded, there will be no collection associated with it.

Returns: Mongo::Collection



19
20
21
22
23
# File 'lib/mongoid/collections.rb', line 19

def collection
  raise Errors::InvalidCollection.new(self) if embedded?
  self._collection || set_collection
  add_indexes; self._collection
end

#store_in(name) ⇒ Object

Macro for setting the collection name to store in.

Example:

Person.store_in :populdation



30
31
32
33
# File 'lib/mongoid/collections.rb', line 30

def store_in(name)
  self.collection_name = name.to_s
  set_collection
end