Class: Sunspot::Query::Sort
- Inherits:
-
Object
- Object
- Sunspot::Query::Sort
- Defined in:
- lib/sunspot/query/sort.rb
Overview
The Sort class is a query component representing a sort by a given field.
Constant Summary collapse
- ASCENDING =
:nodoc:
Set.new([:asc, :ascending])
- DESCENDING =
Set.new([:desc, :descending])
Instance Method Summary collapse
-
#initialize(field, direction = nil) ⇒ Sort
constructor
A new instance of Sort.
- #to_params ⇒ Object
Constructor Details
#initialize(field, direction = nil) ⇒ Sort
Returns a new instance of Sort.
10 11 12 |
# File 'lib/sunspot/query/sort.rb', line 10 def initialize(field, direction = nil) @field, @direction = field, (direction || :asc).to_sym end |
Instance Method Details
#to_params ⇒ Object
14 15 16 |
# File 'lib/sunspot/query/sort.rb', line 14 def to_params { :sort => [{ @field.indexed_name.to_sym => direction_for_solr }] } end |