Class: Druid::BooleanFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/druid/filter.rb

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

#!Object



264
265
266
267
268
269
270
271
272
273
274
# File 'lib/druid/filter.rb', line 264

def !()
  if @type.to_s == 'not'
    self.field
    self
  else
    BooleanFilter.new({
      type: 'not',
      field: self,
    })
  end
end

#&(other) ⇒ Object



240
241
242
243
244
245
246
247
248
249
250
# File 'lib/druid/filter.rb', line 240

def &(other)
  if @type.to_s == 'and'
    self.fields << other
    self
  else
    BooleanFilter.new({
      type: 'and',
      fields: [self, other],
    })
  end
end

#|(other) ⇒ Object



252
253
254
255
256
257
258
259
260
261
262
# File 'lib/druid/filter.rb', line 252

def |(other)
  if @type.to_s == 'or'
    self.fields << other
    self
  else
    BooleanFilter.new({
      type: 'or',
      fields: [self, other],
    })
  end
end