Class: Druid::DimensionFilter
Instance Attribute Summary
Attributes inherited from Filter
#dimension, #field, #fields, #function, #pattern, #type, #value
Instance Method Summary
collapse
#!, #&, #|
Methods inherited from Filter
#as_json, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Druid::Filter
Instance Method Details
#bound(params) ⇒ Object
169
170
171
|
# File 'lib/druid/filter.rb', line 169
def bound(params)
BoundFilter.new(@dimension, params)
end
|
#eq(value) ⇒ Object
Also known as:
==
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/druid/filter.rb', line 177
def eq(value)
case value
when ::Array
self.in(value)
when ::Regexp
self.regexp(value)
else
@type = 'selector'
@value = value
end
self
end
|
#filter_multiple(values, operator, method) ⇒ Object
206
207
208
209
210
211
212
213
214
215
|
# File 'lib/druid/filter.rb', line 206
def filter_multiple(values, operator, method)
::Kernel.raise 'Values cannot be empty' if values.empty?
return self.__send__(method, values[0]) if values.length == 1
BooleanFilter.new({
type: operator,
fields: values.map do |value|
DimensionFilter.new(dimension: @dimension).__send__(method, value)
end
})
end
|
#in(*args) ⇒ Object
198
199
200
|
# File 'lib/druid/filter.rb', line 198
def in(*args)
filter_multiple(args.flatten, 'or', :eq)
end
|
#in_circ(bounds) ⇒ Object
165
166
167
|
# File 'lib/druid/filter.rb', line 165
def in_circ(bounds)
CircFilter.new(@dimension, bounds)
end
|
#in_rec(bounds) ⇒ Object
161
162
163
|
# File 'lib/druid/filter.rb', line 161
def in_rec(bounds)
RecFilter.new(@dimension, bounds)
end
|
#javascript(js) ⇒ Object
242
243
244
|
# File 'lib/druid/filter.rb', line 242
def javascript(js)
JavascriptFilter.new(@dimension, js)
end
|
#neq(value) ⇒ Object
Also known as:
!=
192
193
194
|
# File 'lib/druid/filter.rb', line 192
def neq(value)
return !self.eq(value)
end
|
#nin(*args) ⇒ Object
Also known as:
not_in
202
203
204
|
# File 'lib/druid/filter.rb', line 202
def nin(*args)
filter_multiple(args.flatten, 'and', :neq)
end
|
#regexp(r) ⇒ Object
219
220
221
222
223
224
|
# File 'lib/druid/filter.rb', line 219
def regexp(r)
r = ::Regexp.new(r) unless r.is_a?(::Regexp)
@pattern = r.inspect[1...-1] @type = 'regex'
self
end
|
#search(params) ⇒ Object
173
174
175
|
# File 'lib/druid/filter.rb', line 173
def search(params)
SearchFilter.new(@dimension, params)
end
|