Method: JSONAPI::Resource.construct_order_options

Defined in:
lib/jsonapi/resource.rb

.construct_order_options(sort_params) ⇒ Object



1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
# File 'lib/jsonapi/resource.rb', line 1083

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