Class: PeaceLove::Cursor
- Inherits:
-
Object
- Object
- PeaceLove::Cursor
- Includes:
- Enumerable
- Defined in:
- lib/peace_love/cursor.rb
Instance Attribute Summary collapse
-
#mongo_cursor ⇒ Object
readonly
Returns the value of attribute mongo_cursor.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(cursor, collection) ⇒ Cursor
constructor
A new instance of Cursor.
- #next_document ⇒ Object
- #to_a ⇒ Object
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_cursor ⇒ Object (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
#each ⇒ Object
12 13 14 |
# File 'lib/peace_love/cursor.rb', line 12 def each @cursor.each {|doc| yield @collection.__wrap(doc)} end |
#next_document ⇒ Object
16 17 18 |
# File 'lib/peace_love/cursor.rb', line 16 def next_document @collection.__wrap( @cursor.next_document ) end |
#to_a ⇒ Object
20 21 22 |
# File 'lib/peace_love/cursor.rb', line 20 def to_a @cursor.to_a.map {|doc| @collection.__wrap(doc)} end |