Class: PaginateResponder::PagyAdapter
- Inherits:
-
Base
- Object
- Base
- PaginateResponder::PagyAdapter
show all
- Defined in:
- lib/paginate-responder/pagy_adapter.rb
Overview
Pagination adapter for pagy.
Instance Attribute Summary
Attributes inherited from Base
#resource, #responder
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#controller, #initialize, #request, #response
Class Method Details
.pagy_method(resource) ⇒ Object
41
42
43
|
# File 'lib/paginate-responder/pagy_adapter.rb', line 41
def pagy_method(resource)
i[limit offset].all? {|model_method| resource.respond_to?(model_method) } ? :pagy : :pagy_array
end
|
.suitable?(resource, responder) ⇒ Boolean
37
38
39
|
# File 'lib/paginate-responder/pagy_adapter.rb', line 37
def suitable?(resource, responder)
responder.controller.respond_to?(pagy_method(resource), true)
end
|
Instance Method Details
#default_max_per_page ⇒ Object
26
27
28
|
# File 'lib/paginate-responder/pagy_adapter.rb', line 26
def default_max_per_page
Pagy::VARS[:max_items] || BigDecimal::INFINITY
end
|
#default_per_page ⇒ Object
22
23
24
|
# File 'lib/paginate-responder/pagy_adapter.rb', line 22
def default_per_page
Pagy::VARS[:items]
end
|
#paginate ⇒ Object
8
9
10
11
12
|
# File 'lib/paginate-responder/pagy_adapter.rb', line 8
def paginate
self.pagy, self.pagy_resource = controller.send(self.class.pagy_method(resource), resource, page: page,
items: per_page,)
pagy_resource
end
|
#paginate! ⇒ Object
30
31
32
33
34
|
# File 'lib/paginate-responder/pagy_adapter.rb', line 30
def paginate!
paginate.tap do
update
end
end
|
#total_count ⇒ Object
18
19
20
|
# File 'lib/paginate-responder/pagy_adapter.rb', line 18
def total_count
pagy.count
end
|
#total_pages ⇒ Object
14
15
16
|
# File 'lib/paginate-responder/pagy_adapter.rb', line 14
def total_pages
pagy.pages
end
|