Sha256: fcbdf18979c1bd05960bb5a5a21bd7ce9c806ed0c8dc07b0149fcc1105d48a9d

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

require "transformator/transformation/step"
require_relative "../request_transformation"

class Skala::ElasticsearchAdapter::Search::RequestTransformation::
  AddSort < Transformator::Transformation::Step

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skala-1.1.0 lib/skala/elasticsearch_adapter/search/request_transformation/add_sort.rb