Method: Mongory::QueryBuilder#each

Defined in:
lib/mongory/query_builder.rb

#each {|record| ... } ⇒ Enumerator, void

Iterates through all records that match the current matcher. Uses the standard matcher implementation.

Yield Parameters:

  • record (Object)

    each matching record

Returns:

  • (Enumerator)

    if no block given

  • (void)

    if block given



45
46
47
48
49
50
51
52
53
# File 'lib/mongory/query_builder.rb', line 45

def each
  return to_enum(:each) unless block_given?

  @matcher.prepare_query
  @records.each do |record|
    @context.current_record = record
    yield record if @matcher.match?(record)
  end
end