Class: Ddr::Index::Filter
- Inherits:
-
Object
- Object
- Ddr::Index::Filter
- Defined in:
- lib/ddr/index/filter.rb
Instance Attribute Summary collapse
-
#clauses ⇒ Object
Returns the value of attribute clauses.
Instance Method Summary collapse
- #absent(field) ⇒ Object
- #before(field, date_time) ⇒ Object
- #before_days(field, days) ⇒ Object
-
#initialize ⇒ Filter
constructor
A new instance of Filter.
- #present(field) ⇒ Object
-
#raw(*clauses) ⇒ Object
Adds clause (String) w/o escaping.
- #where(conditions) ⇒ Object
Constructor Details
#initialize ⇒ Filter
Returns a new instance of Filter.
10 11 12 |
# File 'lib/ddr/index/filter.rb', line 10 def initialize @clauses = [ ] end |
Instance Attribute Details
#clauses ⇒ Object
Returns the value of attribute clauses.
8 9 10 |
# File 'lib/ddr/index/filter.rb', line 8 def clauses @clauses end |
Instance Method Details
#absent(field) ⇒ Object
35 36 37 |
# File 'lib/ddr/index/filter.rb', line 35 def absent(field) raw QueryClause.absent(field) end |
#before(field, date_time) ⇒ Object
39 40 41 |
# File 'lib/ddr/index/filter.rb', line 39 def before(field, date_time) raw QueryClause.before(field, date_time) end |
#before_days(field, days) ⇒ Object
43 44 45 |
# File 'lib/ddr/index/filter.rb', line 43 def before_days(field, days) raw QueryClause.before_days(field, days) end |
#present(field) ⇒ Object
31 32 33 |
# File 'lib/ddr/index/filter.rb', line 31 def present(field) raw QueryClause.present(field) end |
#raw(*clauses) ⇒ Object
Adds clause (String) w/o escaping
26 27 28 29 |
# File 'lib/ddr/index/filter.rb', line 26 def raw(*clauses) self.clauses += clauses self end |
#where(conditions) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ddr/index/filter.rb', line 14 def where(conditions) clauses = conditions.map do |field, value| if value.respond_to?(:each) QueryClause.or_values(field, *value) else QueryClause.term(field, value) end end raw *clauses end |