Class: Ddr::Index::Query

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ddr/index/query.rb

Instance Method Summary collapse

Constructor Details

#initialize(**args, &block) ⇒ Query

Returns a new instance of Query.



18
19
20
21
22
23
# File 'lib/ddr/index/query.rb', line 18

def initialize(**args, &block)
  super(**args)
  if block_given?
    build(&block)
  end
end

Instance Method Details

#build(&block) ⇒ Object



50
51
52
53
# File 'lib/ddr/index/query.rb', line 50

def build(&block)
  QueryBuilder.new(self, &block)
  self
end

#csv(**opts) ⇒ Object



38
39
40
# File 'lib/ddr/index/query.rb', line 38

def csv(**opts)
  CSVQueryResult.new(self, **opts)
end

#filter_clausesObject



42
43
44
# File 'lib/ddr/index/query.rb', line 42

def filter_clauses
  filters.map(&:clauses).flatten
end

#inspectObject



25
26
27
28
# File 'lib/ddr/index/query.rb', line 25

def inspect
  "#<#{self.class.name} q=#{q.inspect}, filters=#{filters.inspect}," \
  " sort=#{sort.inspect}, rows=#{rows.inspect}, fields=#{fields.inspect}>"
end

#query_paramsObject



46
47
48
# File 'lib/ddr/index/query.rb', line 46

def query_params
  QueryParams.new(self)
end

#resultObject



34
35
36
# File 'lib/ddr/index/query.rb', line 34

def result
  QueryResult.new(self)
end

#to_sObject



30
31
32
# File 'lib/ddr/index/query.rb', line 30

def to_s
  URI.encode_www_form(params)
end