Class: Chewie::Query::Bool

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/chewie/query/bool.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) ⇒ Bool

Returns a new instance of Bool.



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

def initialize(handler, filters)
  @attribute = handler[:attribute]
  @query_format = handler[:format]
  @with = handler[:with]
  @value = filters[attribute]
  @combine = handler[:combine]
  @filters = filters
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



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

def attribute
  @attribute
end

#combineObject (readonly)

Returns the value of attribute combine.



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

def combine
  @combine
end

#filtersObject (readonly)

Returns the value of attribute filters.



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

def filters
  @filters
end

#query_formatObject (readonly)

Returns the value of attribute query_format.



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

def query_format
  @query_format
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

#withObject (readonly)

Returns the value of attribute with.



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

def with
  @with
end

Instance Method Details

#buildObject



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

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

  context(with) do
    { attribute => exposed_value }
  end
end