Class: JsonapiCompliable::Scoping::Sort
- Inherits:
-
Base
- Object
- Base
- JsonapiCompliable::Scoping::Sort
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
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
|