Class: Chewie::Query::FullText

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/chewie/query/full_text.rb

Instance Attribute Summary collapse

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

Constructor Details

#initialize(handler, filters) ⇒ FullText

Returns a new instance of FullText.



8
9
10
11
12
13
14
15
16
# File 'lib/chewie/query/full_text.rb', line 8

def initialize(handler, filters)
  @attribute = handler[:attribute]
  @with = handler[:with]
  @query = handler[:query]
  @clause = handler[:clause]
  @value = filters[attribute] || filters[:query]
  @options = handler.fetch(:options, {})
  @strategy = clause.present? ? 'clause' : 'attribute'
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



6
7
8
# File 'lib/chewie/query/full_text.rb', line 6

def attribute
  @attribute
end

#clauseObject (readonly)

Returns the value of attribute clause.



6
7
8
# File 'lib/chewie/query/full_text.rb', line 6

def clause
  @clause
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/chewie/query/full_text.rb', line 6

def options
  @options
end

#queryObject (readonly)

Returns the value of attribute query.



6
7
8
# File 'lib/chewie/query/full_text.rb', line 6

def query
  @query
end

#strategyObject (readonly)

Returns the value of attribute strategy.



6
7
8
# File 'lib/chewie/query/full_text.rb', line 6

def strategy
  @strategy
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/chewie/query/full_text.rb', line 6

def value
  @value
end

#withObject (readonly)

Returns the value of attribute with.



6
7
8
# File 'lib/chewie/query/full_text.rb', line 6

def with
  @with
end

Instance Method Details

#buildObject



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

def build
  return {} if value.nil?
  return [] if [value].flatten.empty?

  send("create_with_#{strategy}")
end