Class: MongoDoc::Cursor

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/mongo_doc/cursor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mongo_doc_collection, cursor) ⇒ Cursor

Returns a new instance of Cursor.



9
10
11
12
# File 'lib/mongo_doc/cursor.rb', line 9

def initialize(mongo_doc_collection, cursor)
  self._collection = mongo_doc_collection
  self._cursor = cursor
end

Instance Attribute Details

#_collectionObject

Returns the value of attribute _collection.



5
6
7
# File 'lib/mongo_doc/cursor.rb', line 5

def _collection
  @_collection
end

#_cursorObject

Returns the value of attribute _cursor.



5
6
7
# File 'lib/mongo_doc/cursor.rb', line 5

def _cursor
  @_cursor
end

Instance Method Details

#collectionObject



14
15
16
# File 'lib/mongo_doc/cursor.rb', line 14

def collection
  _collection
end

#eachObject



18
19
20
21
22
# File 'lib/mongo_doc/cursor.rb', line 18

def each
  _cursor.each do |next_document|
    yield MongoDoc::BSON.decode(next_document)
  end
end

#next_documentObject



24
25
26
# File 'lib/mongo_doc/cursor.rb', line 24

def next_document
  MongoDoc::BSON.decode(_cursor.next_document)
end

#to_aObject



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

def to_a
  MongoDoc::BSON.decode(_cursor.to_a)
end