Class: ElasticsearchQuery::Sort
- Inherits:
-
Object
- Object
- ElasticsearchQuery::Sort
- Defined in:
- lib/elasticsearch_query/sort.rb
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Sort
constructor
A new instance of Sort.
- #to_hash ⇒ Object
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_hash ⇒ Object
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 |