class Monga::BlockCursor

Public Instance Methods

all() click to toggle source
# File lib/monga/cursor.rb, line 276
def all
  documents = []
  each_batch do |batch|
    documents += batch
  end
  documents
end
each_batch() { |batch| ... } click to toggle source
# File lib/monga/cursor.rb, line 248
def each_batch
  begin
    batch, more = next_batch
    yield batch if more || batch
  end while more
end
each_doc() { |doc| ... } click to toggle source
# File lib/monga/cursor.rb, line 268
def each_doc
  begin
    doc, more = next_doc
    yield doc if more || doc
  end while more
end
Also aliased as: each_document
each_document()
Alias for: each_doc
first() click to toggle source
# File lib/monga/cursor.rb, line 284
def first
  resp = limit(1).all
  resp.first
end
next_batch() click to toggle source
# File lib/monga/cursor.rb, line 241
def next_batch
  get_more(get_batch_size) do |err, batch, more|
    raise(err) if err
    return [batch, more]
  end
end
next_doc() click to toggle source
# File lib/monga/cursor.rb, line 255
def next_doc
  if doc = @fetched_docs.shift
    [doc, more?]
  else
    batch, more = next_batch
    @fetched_docs = batch
    doc = @fetched_docs.shift
    m = more || @fetched_docs.any?
    return [doc, m]
  end
end
Also aliased as: next_document
next_document()
Alias for: next_doc