Module: Mongoid::Collections::ClassMethods
- Defined in:
- lib/mongoid/collections.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#collection ⇒ Collection
Returns the collection associated with this
Document
. -
#db ⇒ Mongo::DB
Return the database associated with this collection.
-
#index_information ⇒ Array
Convenience method for getting index information from the collection.
-
#store_in(name, options = {}) ⇒ Object
Macro for setting the collection name to store in.
Instance Method Details
#collection ⇒ Collection
Returns the collection associated with this Document
. If the document is embedded, there will be no collection associated with it unless it’s in a cyclic relation.
54 55 56 57 58 |
# File 'lib/mongoid/collections.rb', line 54 def collection raise Errors::InvalidCollection.new(self) if && !cyclic self._collection || set_collection add_indexes; self._collection end |
#db ⇒ Mongo::DB
Return the database associated with this collection.
66 67 68 |
# File 'lib/mongoid/collections.rb', line 66 def db collection.db end |
#index_information ⇒ Array
Convenience method for getting index information from the collection.
76 77 78 |
# File 'lib/mongoid/collections.rb', line 76 def index_information collection.index_information end |
#store_in(name, options = {}) ⇒ Object
Macro for setting the collection name to store in.
95 96 97 98 |
# File 'lib/mongoid/collections.rb', line 95 def store_in(name, = {}) self.collection_name = name.to_s set_collection() end |