Class: NoSE::Backend::Backend::SortStatementStep
- Inherits:
-
StatementStep
- Object
- StatementStep
- NoSE::Backend::Backend::SortStatementStep
- Defined in:
- lib/nose/backend.rb
Overview
Perform sorting external to the backend
Instance Attribute Summary
Attributes inherited from StatementStep
Instance Method Summary collapse
-
#initialize(_client, _fields, _conditions, step, _next_step, _prev_step) ⇒ SortStatementStep
constructor
A new instance of SortStatementStep.
-
#process(_conditions, results) ⇒ Array<Hash>
Sort results by a list of fields given in the step.
Methods included from Supertype
Constructor Details
#initialize(_client, _fields, _conditions, step, _next_step, _prev_step) ⇒ SortStatementStep
Returns a new instance of SortStatementStep.
263 264 265 266 |
# File 'lib/nose/backend.rb', line 263 def initialize(_client, _fields, _conditions, step, _next_step, _prev_step) @step = step end |
Instance Method Details
#process(_conditions, results) ⇒ Array<Hash>
Sort results by a list of fields given in the step
270 271 272 273 274 275 276 |
# File 'lib/nose/backend.rb', line 270 def process(_conditions, results) results.sort_by! do |row| @step.sort_fields.map do |field| row[field.id] end end end |