Class: Skala::ElasticsearchAdapter::Search::RequestTransformation::AddSort

Inherits:
Transformator::Transformation::Step
  • Object
show all
Defined in:
lib/skala/elasticsearch_adapter/search/request_transformation/add_sort.rb

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/skala/elasticsearch_adapter/search/request_transformation/add_sort.rb', line 7

def call
  source.sort.try do |_sort_requests|
    target["sort"] ||= _sort_requests.map do |_sort_request|
      if _sort_request.order
        { _sort_request.field => { order: _sort_request.order } }
      else
        _sort_request.field
      end
    end
  end
end