Module: Chewie

Includes:
Interface::Bool, Interface::FullText, Interface::TermLevel, Utils
Defined in:
lib/chewie.rb,
lib/chewie/version.rb,
lib/chewie/query/bool.rb,
lib/chewie/interface/bool.rb,
lib/chewie/handler/reduced.rb,
lib/chewie/query/full_text.rb,
lib/chewie/query/term_level.rb,
lib/chewie/interface/full_text.rb,
lib/chewie/interface/term_level.rb

Defined Under Namespace

Modules: Handler, Interface, Query

Constant Summary collapse

VERSION =
"0.2.5"

Instance Method Summary collapse

Methods included from Utils

#clean_filters, #combine_values, #context, #expose_or_return_value, #format_values, #reduce_handlers, #set_handler, #set_query_data

Methods included from Interface::FullText

#match, #multimatch

Methods included from Interface::TermLevel

#fuzzy, #range, #term, #terms

Methods included from Interface::Bool

#filter_by, #must_include, #must_not_include, #should_include

Instance Method Details

#build(query: '', filters: {}, options: {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/chewie.rb', line 22

def build(query: '', filters: {}, options: {})
  query_data = set_query_data(query, filters)
  bool_options = options[:bool] || {}

  match_all_query(options) if query_data[:filters].empty?

  context(:query, options) do
    query_context = reduce_handlers(data: query_data)
    bool_context = context(:bool, bool_options) do
      reduce_handlers(data: query_data, context: :bool)
    end

    query_context.merge(bool_context)
  end
end

#handlersObject



15
16
17
18
19
20
# File 'lib/chewie.rb', line 15

def handlers
  @handlers ||= {
    query: [],
    bool: []
  }
end