Class: JsonapiCompliable::Scoping::Paginate
- Inherits:
-
Base
- Object
- Base
- JsonapiCompliable::Scoping::Paginate
show all
- Defined in:
- lib/jsonapi_compliable/scoping/paginate.rb
Constant Summary
collapse
- MAX_PAGE_SIZE =
1_000
Instance Attribute Summary
Attributes inherited from Base
#query_hash, #resource
Instance Method Summary
collapse
Methods inherited from Base
#apply_standard_or_override, #apply_standard_scope?, #initialize
Instance Method Details
#apply ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/jsonapi_compliable/scoping/paginate.rb', line 5
def apply
if size > MAX_PAGE_SIZE
raise JsonapiCompliable::Errors::UnsupportedPageSize
.new(size, MAX_PAGE_SIZE)
else
super
end
end
|
#apply? ⇒ Boolean
14
15
16
17
18
19
20
|
# File 'lib/jsonapi_compliable/scoping/paginate.rb', line 14
def apply?
if @opts[:default] == false
not [page_param[:size], page_param[:number]].all?(&:nil?)
else
true
end
end
|
#apply_custom_scope ⇒ Object
30
31
32
|
# File 'lib/jsonapi_compliable/scoping/paginate.rb', line 30
def apply_custom_scope
custom_scope.call(@scope, number, size)
end
|
#apply_standard_scope ⇒ Object
26
27
28
|
# File 'lib/jsonapi_compliable/scoping/paginate.rb', line 26
def apply_standard_scope
resource.adapter.paginate(@scope, number, size)
end
|
#custom_scope ⇒ Object
22
23
24
|
# File 'lib/jsonapi_compliable/scoping/paginate.rb', line 22
def custom_scope
resource.
end
|