Class: AgnosticBackend::Queryable::Cloudsearch::Query

Inherits:
Query
  • Object
show all
Defined in:
lib/agnostic_backend/queryable/cloudsearch/query.rb

Instance Attribute Summary

Attributes inherited from Query

#context, #errors, #executor, #options

Attributes inherited from TreeNode

#children, #context

Instance Method Summary collapse

Methods inherited from Query

#set_scroll_cursor, #valid?

Methods inherited from TreeNode

#==, #accept

Methods included from Utilities

included

Constructor Details

#initialize(base, **options) ⇒ Query

Returns a new instance of Query.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/agnostic_backend/queryable/cloudsearch/query.rb', line 6

def initialize(base, **options)
  super
  case options[:parser]
  when :simple
    @executor = Executor.new(self, SimpleVisitor.new, filter_visitor: Visitor.new)
  when :structured
    @executor = Executor.new(self, Visitor.new, filter_visitor: Visitor.new)
  else
    @executor = Executor.new(self, Visitor.new, filter_visitor: Visitor.new)
  end
end

Instance Method Details

#executeObject



18
19
20
# File 'lib/agnostic_backend/queryable/cloudsearch/query.rb', line 18

def execute
  @executor.execute if valid?
end

#execute!Object



22
23
24
25
26
27
28
# File 'lib/agnostic_backend/queryable/cloudsearch/query.rb', line 22

def execute!
  if valid?
    @executor.execute
  else
    raise StandardError, errors
  end
end

#to_sObject



30
31
32
# File 'lib/agnostic_backend/queryable/cloudsearch/query.rb', line 30

def to_s
  @executor.to_s
end