Class: RediSearch::Aggregate::Clauses::SortBy
- Inherits:
-
RediSearch::ApplicationClause
- Object
- RediSearch::ApplicationClause
- RediSearch::Aggregate::Clauses::SortBy
- Defined in:
- lib/redi_search/aggregate/clauses/sort_by.rb
Defined Under Namespace
Classes: Sortable
Instance Method Summary collapse
- #clause ⇒ Object
-
#initialize(fields:) ⇒ SortBy
constructor
A new instance of SortBy.
Methods inherited from RediSearch::ApplicationClause
#clause_order, clause_order, clause_term
Methods included from Validatable
Constructor Details
#initialize(fields:) ⇒ SortBy
Returns a new instance of SortBy.
26 27 28 29 30 31 32 33 |
# File 'lib/redi_search/aggregate/clauses/sort_by.rb', line 26 def initialize(fields:) @fields = fields.flat_map do |field| if field.is_a?(Hash) then field.map { |k, v| Sortable.new(k, v) } else Sortable.new(field) end end end |
Instance Method Details
#clause ⇒ Object
35 36 37 38 39 |
# File 'lib/redi_search/aggregate/clauses/sort_by.rb', line 35 def clause validate! && fields.each(&:validate!) ["SORTBY", fields.count * 2, *fields.flat_map(&:clause)] end |