Module: Trailblazer::Finder::Adapters::ActiveRecord::Sorting

Defined in:
lib/trailblazer/finder/adapters/active_record/sorting.rb

Overview

ActiveRecord Paging Adapter

Class Method Summary collapse

Class Method Details

.set_sorting_handlerObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/trailblazer/finder/adapters/active_record/sorting.rb', line 12

def set_sorting_handler
  ->(sort_attributes, entity) do
    sort_attributes.delete(:handler)
    attributes = []
    sort_attributes.each do |attr|
      attributes << {attr[0].to_s => attr[1]}
    end
    entity.order(attributes)
  end
end