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.



83
84
85
86
# File 'lib/dap/filter/simple.rb', line 83

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.



81
82
83
# File 'lib/dap/filter/simple.rb', line 81

def query
  @query
end

Instance Method Details

#process(doc) ⇒ Object



88
89
90
91
92
# File 'lib/dap/filter/simple.rb', line 88

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