Class: Mongory::CQueryBuilder

Inherits:
QueryBuilder show all
Defined in:
lib/mongory/c_query_builder.rb

Overview

Mongory::CQueryBuilder is a query builder for Mongory::CMatcher. It is used to build a query for a Mongory::CMatcher.

Instance Method Summary collapse

Methods inherited from QueryBuilder

#and, #any_of, #c, #in, #initialize, #limit, #nin, #not, #or, #pluck, #raw_condition, #where, #with_context

Methods included from Utils

included, included_classes, #is_blank?, #is_present?

Constructor Details

This class inherits a constructor from Mongory::QueryBuilder

Instance Method Details

#eachObject Also known as: fast



9
10
11
12
13
14
15
16
# File 'lib/mongory/c_query_builder.rb', line 9

def each
  return to_enum(:each) unless block_given?

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

#explainObject



20
21
22
23
# File 'lib/mongory/c_query_builder.rb', line 20

def explain
  @matcher.match?(@records.first)
  @matcher.explain
end

#traceObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mongory/c_query_builder.rb', line 25

def trace
  return to_enum(:trace) unless block_given?

  @matcher.enable_trace
  @records.each do |record|
    @context.current_record = record
    yield record if @matcher.match?(record)
  end
ensure
  @matcher.print_trace
  @matcher.disable_trace
end