Class: PeaceLove::Cursor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cursor, collection) ⇒ Cursor

Returns a new instance of Cursor.



7
8
9
10
# File 'lib/peace_love/cursor.rb', line 7

def initialize(cursor,collection)
  @collection = collection
  @cursor     = @mongo_cursor = cursor
end

Instance Attribute Details

#mongo_cursorObject (readonly)

Returns the value of attribute mongo_cursor.



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

def mongo_cursor
  @mongo_cursor
end

Instance Method Details

#eachObject



12
13
14
# File 'lib/peace_love/cursor.rb', line 12

def each
  @cursor.each {|doc| yield @collection.__wrap(doc)}
end

#next_documentObject



16
17
18
# File 'lib/peace_love/cursor.rb', line 16

def next_document
  @collection.__wrap( @cursor.next_document )
end

#to_aObject



20
21
22
# File 'lib/peace_love/cursor.rb', line 20

def to_a
  @cursor.to_a.map {|doc| @collection.__wrap(doc)}
end