Class: Stretchy::Clauses::WhereClause
- Inherits:
-
Base
- Object
- Base
- Stretchy::Clauses::WhereClause
show all
- Defined in:
- lib/stretchy/clauses/where_clause.rb
Constant Summary
Constants inherited
from Base
Base::DEFAULT_LIMIT, Base::DEFAULT_OFFSET
Instance Attribute Summary
Attributes inherited from Base
#aggregate_builder, #boost_builder, #index_name, #inverse, #match_builder, #type, #where_builder
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#boost, #get_limit, #get_offset, #inverse?, #limit, #match, #offset, #query_results, #to_search, #where
Constructor Details
#initialize(base, options = {}) ⇒ WhereClause
Returns a new instance of WhereClause.
11
12
13
14
15
16
|
# File 'lib/stretchy/clauses/where_clause.rb', line 11
def initialize(base, options = {})
super(base)
@inverse = options.delete(:inverse)
@should = options.delete(:should)
add_params(options)
end
|
Class Method Details
.tmp(options = {}) ⇒ Object
7
8
9
|
# File 'lib/stretchy/clauses/where_clause.rb', line 7
def self.tmp(options = {})
self.new(Base.new, options)
end
|
Instance Method Details
#geo(field, options = {}) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/stretchy/clauses/where_clause.rb', line 27
def geo(field, options = {})
get_storage(:geos)[field] = {
distance: options[:distance],
geo_point: Stretchy::Types::GeoPoint.new(options)
}
self
end
|
#not(options = {}) ⇒ Object
35
36
37
|
# File 'lib/stretchy/clauses/where_clause.rb', line 35
def not(options = {})
self.class.new(self, options.merge(inverse: true, should: should?))
end
|
#range(field, options = {}) ⇒ Object
22
23
24
25
|
# File 'lib/stretchy/clauses/where_clause.rb', line 22
def range(field, options = {})
get_storage(:ranges)[field] = Stretchy::Types::Range.new(options)
self
end
|
#should(options = {}) ⇒ Object
39
40
41
|
# File 'lib/stretchy/clauses/where_clause.rb', line 39
def should(options = {})
self.class.new(self, options.merge(should: true))
end
|
#should? ⇒ Boolean
18
19
20
|
# File 'lib/stretchy/clauses/where_clause.rb', line 18
def should?
!!@should
end
|
#to_boost(weight = nil) ⇒ Object