Class: Dominus::DocumentCollection
- Inherits:
-
Object
- Object
- Dominus::DocumentCollection
- Includes:
- Enumerable
- Defined in:
- lib/dominus/document_collection.rb
Instance Attribute Summary collapse
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
Class Method Summary collapse
Instance Method Summary collapse
- #all ⇒ Object
- #count ⇒ Object
- #each ⇒ Object
-
#initialize(collection) ⇒ DocumentCollection
constructor
A new instance of DocumentCollection.
Constructor Details
#initialize(collection) ⇒ DocumentCollection
Returns a new instance of DocumentCollection.
11 12 13 14 15 |
# File 'lib/dominus/document_collection.rb', line 11 def initialize(collection) @collection = collection ObjectSpace.define_finalizer(self, self.class.cleanup(collection)) end |
Instance Attribute Details
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
5 6 7 |
# File 'lib/dominus/document_collection.rb', line 5 def documents @documents end |
Class Method Details
.cleanup(collection) ⇒ Object
7 8 9 |
# File 'lib/dominus/document_collection.rb', line 7 def self.cleanup(collection) proc { collection.recycle } end |
Instance Method Details
#all ⇒ Object
27 28 29 |
# File 'lib/dominus/document_collection.rb', line 27 def all @collection end |
#count ⇒ Object
31 32 33 |
# File 'lib/dominus/document_collection.rb', line 31 def count @count ||= all.count end |