Sha256: 20e7fac7fafdcfa612ff7ad7166dd0c09c73ed610567bb54898ad372c86fdd9f
Contents?: true
Size: 828 Bytes
Versions: 20
Compression:
Stored size: 828 Bytes
Contents
module Sunspot module Query # # The SortComposite class encapsulates an ordered collection of Sort # objects. It's necessary to keep this as a separate class as Solr takes # the sort as a single parameter, so adding sorts as regular components # would not merge correctly in the #to_params method. # class SortComposite #:nodoc: def initialize @sorts = [] end # # Add a sort to the composite # def <<(sort) @sorts << sort end # # Combine the sorts into a single param by joining them # def to_params(prefix = "") unless @sorts.empty? key = "#{prefix}sort".to_sym { key => @sorts.map { |sort| sort.to_param } * ', ' } else {} end end end end end
Version data entries
20 entries across 20 versions & 5 rubygems