module Trailblazer::Finder::Adapters::Sequel::Sorting
ActiveRecord
Paging
Adapter
Public Instance Methods
set_sorting_handler()
click to toggle source
# File lib/trailblazer/finder/adapters/sequel/sorting.rb, line 12 def set_sorting_handler lambda do |sort_attributes, entity| sort_attributes.delete(:handler) attributes = [] sort_attributes.each do |attr| attributes << (::Sequel.send attr[1], attr[0].to_sym) end result = [] result << [:order, attributes.first] if attributes.is_a? Array attributes.drop(1).each { |x| result << [:order_append, x] } result.reduce(entity) { |obj, method_and_args| obj.send(*method_and_args) } end end