Module: Chewie::Interface::Bool

Included in:
Chewie
Defined in:
lib/chewie/interface/bool.rb

Instance Method Summary collapse

Instance Method Details

#filter_by(attribute, with:, combine: [], format: nil) ⇒ Hash

Note:

See README#filtering-by-associations use case for :combine and :filter options

Returns A valid bool query.

Parameters:

  • attribute (Symbol)

    Field you wish to search

  • with (Symbol)

    Specify the term-level query [term, terms, range]

  • combine (Array) (defaults to: [])

    Target additional filter values to be combined in the formatted output (optional)

  • format (Lambda) (defaults to: nil)

    Define custom output with :combine values at runtime (optional)

Returns:

  • (Hash)

    A valid bool query



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/chewie/interface/bool.rb', line 11

def filter_by(attribute, with:, combine: [], format: nil)
  handler = {
    query: :filter,
    attribute: attribute, 
    with: with,
    combine: combine, 
    format: format,
    query_type: :bool,
  }
  set_handler(context: :bool, handler: handler)
end

#must_include(attribute, with:, combine: [], format: nil) ⇒ Hash

Note:

See README#filtering-by-associations use case for :combine and :filter options

Returns A valid bool query.

Parameters:

  • attribute (Symbol)

    Field you wish to search

  • with (Symbol)

    Specify the term-level query [term, terms, range]

  • combine (Array) (defaults to: [])

    Target additional filter values to be combined in the formatted output (optional)

  • format (Lambda) (defaults to: nil)

    Define custom output with :combine values at runtime (optional)

Returns:

  • (Hash)

    A valid bool query



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/chewie/interface/bool.rb', line 50

def must_include(attribute, with:, combine: [], format: nil)
  handler = {
    query: :must,
    attribute: attribute, 
    with: with,
    combine: combine, 
    format: format,
    query_type: :bool,
  }

  set_handler(context: :bool, handler: handler)
end

#must_not_include(attribute, with:, combine: [], format: nil) ⇒ Hash

Note:

See README#filtering-by-associations use case for :combine and :filter options

Returns A valid bool query.

Parameters:

  • attribute (Symbol)

    Field you wish to search

  • with (Symbol)

    Specify the term-level query [term, terms, range]

  • combine (Array) (defaults to: [])

    Target additional filter values to be combined in the formatted output (optional)

  • format (Lambda) (defaults to: nil)

    Define custom output with :combine values at runtime (optional)

Returns:

  • (Hash)

    A valid bool query



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/chewie/interface/bool.rb', line 37

def must_not_include(attribute, with:, combine: [], format: nil)
  handler = {
    query: :must_not,
    attribute: attribute, 
    with: with,
    combine: combine, 
    format: format,
    query_type: :bool,
  }
  set_handler(context: :bool, handler: handler)
end

#should_include(attribute, with:, combine: [], format: nil) ⇒ Hash

Note:

See README#filtering-by-associations use case for :combine and :filter options

Returns A valid bool query.

Parameters:

  • attribute (Symbol)

    Field you wish to search

  • with (Symbol)

    Specify the term-level query [term, terms, range]

  • combine (Array) (defaults to: [])

    Target additional filter values to be combined in the formatted output (optional)

  • format (Lambda) (defaults to: nil)

    Define custom output with :combine values at runtime (optional)

Returns:

  • (Hash)

    A valid bool query



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/chewie/interface/bool.rb', line 24

def should_include(attribute, with:, combine: [], format: nil)
  handler = {
    query: :should,
    attribute: attribute, 
    with: with,
    combine: combine, 
    format: format,
    query_type: :bool,
  }
  set_handler(context: :bool, handler: handler)
end