Class: NoSE::Backend::Backend::SortStatementStep

Inherits:
StatementStep show all
Defined in:
lib/nose/backend.rb

Overview

Perform sorting external to the backend

Instance Attribute Summary

Attributes inherited from StatementStep

#index

Instance Method Summary collapse

Methods included from Supertype

included

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

Returns:



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