Module: ElasticsearchRecord::Relation::ValueMethods

Defined in:
lib/elasticsearch_record/relation/value_methods.rb

Instance Method Summary collapse

Instance Method Details

#aggs_clause ⇒ Object



36
37
38
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 36

def aggs_clause
  @values.fetch(:aggs, ElasticsearchRecord::Relation::QueryClauseTree.empty)
end

#aggs_clause=(value) ⇒ Object



40
41
42
43
44
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 40

def aggs_clause=(value)
  assert_modifiable!

  @values[:aggs] = value
end

#configure_value ⇒ Object



16
17
18
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 16

def configure_value
  @values.fetch(:configure, {})
end

#configure_value=(value) ⇒ Object



20
21
22
23
24
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 20

def configure_value=(value)
  assert_modifiable!

  @values[:configure] = value
end

#kind_value ⇒ Object

holds the query kind



5
6
7
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 5

def kind_value
  @values.fetch(:kind, nil)
end

#kind_value=(value) ⇒ Object



9
10
11
12
13
14
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 9

def kind_value=(value)
  # checks if records are already loaded - in this case we cannot mutate the query anymore
  assert_modifiable!

  @values[:kind] = value.to_sym
end

#limit!(value) ⇒ Object

overwrite the limit! method, since the default implementation casts the provided value through Integer() before it reaches the limit_value= setter - which would raise for our special values ('max' & Float::INFINITY).



49
50
51
52
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 49

def limit!(value)
  self.limit_value = value
  self
end

#limit_value=(limit) ⇒ Object

overwrite the limit_value setter, to provide a special behaviour of auto-setting the max_result_window.



55
56
57
58
59
60
61
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 55

def limit_value=(limit)
  if limit == '__max__' || limit == Float::INFINITY || (limit.nil? && delegate_query_nil_limit?)
    super(max_result_window)
  else
    super(limit)
  end
end

#query_clause ⇒ Object



26
27
28
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 26

def query_clause
  @values.fetch(:query, ElasticsearchRecord::Relation::QueryClauseTree.empty)
end

#query_clause=(value) ⇒ Object



30
31
32
33
34
# File 'lib/elasticsearch_record/relation/value_methods.rb', line 30

def query_clause=(value)
  assert_modifiable!

  @values[:query] = value
end