Class: Sunspot::Query::Sort::FieldSort
- Inherits:
-
Abstract
- Object
- Abstract
- Sunspot::Query::Sort::FieldSort
- Defined in:
- sunspot/lib/sunspot/query/sort.rb
Overview
A FieldSort is the usual kind of sort, by the value of a particular field, ascending or descending
Instance Method Summary (collapse)
-
- (FieldSort) initialize(field, direction = nil)
constructor
A new instance of FieldSort.
- - (Object) to_param
Constructor Details
- (FieldSort) initialize(field, direction = nil)
A new instance of FieldSort
62 63 64 65 66 67 |
# File 'sunspot/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
- (Object) to_param
69 70 71 |
# File 'sunspot/lib/sunspot/query/sort.rb', line 69 def to_param "#{@field.indexed_name.to_sym} #{direction_for_solr}" end |