Method: JSONAPI::Resource.construct_order_options

Defined in:
lib/jsonapi/resource.rb

.construct_order_options(sort_params) ⇒ Object



955
956
957
958
959
960
961
962
963
964
# File 'lib/jsonapi/resource.rb', line 955

def construct_order_options(sort_params)
  sort_params ||= default_sort

  return {} unless sort_params

  sort_params.each_with_object({}) do |sort, order_hash|
    field = sort[:field].to_s == 'id' ? _primary_key : sort[:field].to_s
    order_hash[field] = sort[:direction]
  end
end