Sha256: 7329f480667e9fa8647d9c2ed8dcca9be64ebfd4e485a18fbc0940738467c5dc
Contents?: true
Size: 962 Bytes
Versions: 16
Compression:
Stored size: 962 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 # # Check sort presence # def include?(sort) @sorts.any? { |s| s.to_param.include?(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
16 entries across 16 versions & 2 rubygems