Class: JsonapiCompliable::Scoping::Sort

Inherits:
Base
  • Object
show all
Defined in:
lib/jsonapi_compliable/scoping/sort.rb

Instance Attribute Summary

Attributes inherited from Base

#query_hash, #resource

Instance Method Summary collapse

Methods inherited from Base

#apply, #apply?, #apply_standard_or_override, #apply_standard_scope?, #initialize

Constructor Details

This class inherits a constructor from JsonapiCompliable::Scoping::Base

Instance Method Details

#apply_custom_scopeObject



14
15
16
17
18
19
# File 'lib/jsonapi_compliable/scoping/sort.rb', line 14

def apply_custom_scope
  each_sort do |attribute, direction|
    @scope = custom_scope.call(@scope, attribute, direction)
  end
  @scope
end

#apply_standard_scopeObject



7
8
9
10
11
12
# File 'lib/jsonapi_compliable/scoping/sort.rb', line 7

def apply_standard_scope
  each_sort do |attribute, direction|
    @scope = resource.adapter.order(@scope, attribute, direction)
  end
  @scope
end

#custom_scopeObject



3
4
5
# File 'lib/jsonapi_compliable/scoping/sort.rb', line 3

def custom_scope
  resource.sorting
end