Class: Dap::Filter::FilterWhere
- Inherits:
-
Object
- Object
- Dap::Filter::FilterWhere
- 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
-
#query ⇒ Object
Returns the value of attribute query.
Instance Method Summary collapse
-
#initialize(args) ⇒ FilterWhere
constructor
A new instance of FilterWhere.
- #process(doc) ⇒ Object
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
#query ⇒ Object
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 |