Class: JsonapiCompliable::Scoping::Sort

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

Instance Method Summary collapse

Instance Method Details

#apply_custom_scope ⇒ Object



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_scope ⇒ Object



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_scope ⇒ Object



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

def custom_scope
  resource.sorting
end