Class: Elos::QueryBuilder::Base

Inherits:
Object
  • Object
show all
Includes:
Filters, Queries
Defined in:
lib/elos/query_builder/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'lib/elos/query_builder/base.rb', line 5

def initialize(params)
  @klass = params.delete(:class)
  @params = params
end

Instance Method Details

#wrap_buildObject



10
11
12
13
14
15
16
17
18
# File 'lib/elos/query_builder/base.rb', line 10

def wrap_build
  query = build
  return query if !@klass.respond_to?(:physically_destroy?) || @klass.physically_destroy?
  original_query = query[:query]
  filter = term_filter(:_destroyed, value: false)
  query[:query] = { filtered: { query: original_query, filter: filter } }
  # puts JSON.pretty_generate(query)
  query
end