Class: Dap::Filter::FilterWhere

Inherits:
Object
  • Object
show all
Defined in:
lib/dap/filter/simple.rb

Overview

where ‘some.field == some_value’ where ‘some.field != some_value’ TODO: do something other than basic string comparison. Would be nice to have where ‘some.field > 2’, etc

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ FilterWhere

Returns a new instance of FilterWhere.



150
151
152
153
# File 'lib/dap/filter/simple.rb', line 150

def initialize(args)
  fail "Expected 3 arguments to 'where' but got #{args.size}" unless args.size == 3
  self.query = args
end

Instance Attribute Details

#queryObject

Returns the value of attribute query.



148
149
150
# File 'lib/dap/filter/simple.rb', line 148

def query
  @query
end

Instance Method Details

#process(doc) ⇒ Object



155
156
157
158
159
# File 'lib/dap/filter/simple.rb', line 155

def process(doc)
  field, operator, expected = self.query
  return [ doc ] if doc.has_key?(field) and doc[field].send(operator, expected)
  [ ]
end