Class: ElasticsearchQuery::Sort

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticsearch_query/sort.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Sort

Returns a new instance of Sort.



3
4
5
# File 'lib/elasticsearch_query/sort.rb', line 3

def initialize( params = {} )
  @params  = params
end

Instance Method Details

#to_hashObject



7
8
9
10
11
12
13
14
# File 'lib/elasticsearch_query/sort.rb', line 7

def to_hash
  return {} if sorts&.empty?
  if sorts.length == 1
    { sort: sorts.first }
  else
    { sort: sorts }
  end
end