Class: Tire::Search::FilteredQuery
- Inherits:
-
Object
- Object
- Tire::Search::FilteredQuery
- Defined in:
- lib/tire/search/query.rb
Instance Method Summary collapse
- #filter(type, *options) ⇒ Object
-
#initialize(&block) ⇒ FilteredQuery
constructor
A new instance of FilteredQuery.
- #query(options = {}, &block) ⇒ Object
- #to_hash ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(&block) ⇒ FilteredQuery
163 164 165 166 |
# File 'lib/tire/search/query.rb', line 163 def initialize(&block) @value = {} block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given? end |
Instance Method Details
#filter(type, *options) ⇒ Object
173 174 175 176 177 178 |
# File 'lib/tire/search/query.rb', line 173 def filter(type, *) @value[:filter] ||= {} @value[:filter][:and] ||= [] @value[:filter][:and] << Filter.new(type, *).to_hash @value end |
#query(options = {}, &block) ⇒ Object
168 169 170 171 |
# File 'lib/tire/search/query.rb', line 168 def query(={}, &block) @value[:query] = Query.new(&block).to_hash @value end |
#to_hash ⇒ Object
180 181 182 |
# File 'lib/tire/search/query.rb', line 180 def to_hash @value end |
#to_json(options = {}) ⇒ Object
184 185 186 |
# File 'lib/tire/search/query.rb', line 184 def to_json(={}) to_hash.to_json end |