Sha256: 7a4eafc53751b650d6cc04546dd274c89b67692c81f32b19669d8f16f0230ce6
Contents?: true
Size: 729 Bytes
Versions: 12
Compression:
Stored size: 729 Bytes
Contents
module JsonapiCompliable class Scoping::Sort < Scoping::Base def custom_scope resource.sorting end def apply_standard_scope each_sort do |attribute, direction| @scope = resource.adapter.order(@scope, attribute, direction) end @scope end def apply_custom_scope each_sort do |attribute, direction| @scope = custom_scope.call(@scope, attribute, direction) end @scope end private def each_sort sort_param.each do |sort_hash| yield sort_hash.keys.first, sort_hash.values.first end end def sort_param @sort_param ||= query_hash[:sort].empty? ? resource.default_sort : query_hash[:sort] end end end
Version data entries
12 entries across 12 versions & 1 rubygems