Method: Mongoid::Contextual::MapReduce#each

Defined in:
lib/mongoid/contextual/map_reduce.rb

#eachEnumerator

Iterates over each of the documents in the map/reduce, excluding the extra information that was passed back from the database.

Examples:

Iterate over the results.

map_reduce.each do |doc|
  p doc
end

Returns:

  • (Enumerator)

    The enumerator.

Since:

  • 3.0.0



34
35
36
37
38
39
40
41
42
# File 'lib/mongoid/contextual/map_reduce.rb', line 34

def each
  if block_given?
    documents.each do |doc|
      yield doc
    end
  else
    to_enum
  end
end