Class: Sunspot::Query::Sort::FieldSort
- Defined in:
- lib/sunspot/query/sort.rb
Overview
A FieldSort is the usual kind of sort, by the value of a particular field, ascending or descending
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(field, direction = nil) ⇒ FieldSort
constructor
A new instance of FieldSort.
- #to_param ⇒ Object
Constructor Details
#initialize(field, direction = nil) ⇒ FieldSort
Returns a new instance of FieldSort.
62 63 64 65 66 67 |
# File 'lib/sunspot/query/sort.rb', line 62 def initialize(field, direction = nil) if field.multiple? raise(ArgumentError, "#{field.name} cannot be used for ordering because it is a multiple-value field") end @field, @direction = field, (direction || :asc).to_sym end |
Instance Method Details
#to_param ⇒ Object
69 70 71 |
# File 'lib/sunspot/query/sort.rb', line 69 def to_param "#{@field.indexed_name.to_sym} #{direction_for_solr}" end |