Sha256: 6d8ce82870791efe63aa2851420b6e0f68de61fbb20d1986e2c8f7c131ce6ce5

Contents?: true

Size: 602 Bytes

Versions: 5

Compression:

Stored size: 602 Bytes

Contents

module DynamicSunspotSearch
  module Translator
    module OrderBy
      def self.apply(query_object, order_by)
        return unless order_by.present?
        query_object.tap do |search|
          Array.wrap(order_by).each do |order_options|
            case order_options
            when Hash
              field, direction = order_options.first
              search.order_by(field, direction)
            when Symbol, String
              search.order_by(order_options)
            else
              raise NotImplementedError
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dynamic_sunspot_search-0.1.4 lib/dynamic_sunspot_search/translator/order_by.rb
dynamic_sunspot_search-0.1.3 lib/dynamic_sunspot_search/translator/order_by.rb
dynamic_sunspot_search-0.1.2 lib/dynamic_sunspot_search/translator/order_by.rb
dynamic_sunspot_search-0.1.1 lib/dynamic_sunspot_search/translator/order_by.rb
dynamic_sunspot_search-0.1.0 lib/dynamic_sunspot_search/translator/order_by.rb