next_page 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/next_page/pagination_attributes.rb +8 -4
- data/lib/next_page/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3a633fa748d4bdcff2576c514993b13373a95d999680ef06ef0439ba9f849c3
|
4
|
+
data.tar.gz: 58f4616e60f4fe84583a03efe134eac635cf19fee0d5da85c99d9790203cdfc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d91211f3d61c31c98ec05b8512fc0a277ad13490f654c272b5ec77fd1539cc83f6c17bd87169b18a4d66b8a713237da6858543cda2d45bf6041e3c145c4ecd20
|
7
|
+
data.tar.gz: 9617247dbad11b9ef5ef083f489728c565a901e632d77a59c184d25ae0ea48d3e55cf4dbd1e9f30a8e1d7c089dd7616822f786b5bebb21d245ea9890364a3fea
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
[](https://badge.fury.io/rb/next_page)
|
2
2
|
[](https://github.com/RockSolt/next_page/actions?query=workflow%3ARuboCop)
|
3
|
+
[](https://codeclimate.com/github/RockSolt/next_page/maintainability)
|
3
4
|
|
4
5
|
# NextPage
|
5
6
|
Basic pagination for Rails controllers.
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module NextPage
|
4
4
|
# = Pagination Attributes
|
5
5
|
#
|
6
|
-
# Module PaginationAttributes adds in methods required for pagination links: current_page, next_page,
|
7
|
-
# It reads the offset and limit on the query to determine the values.
|
6
|
+
# Module PaginationAttributes adds in methods required for pagination links: previous_page, current_page, next_page,
|
7
|
+
# and total_pages. It reads the offset and limit on the query to determine the values.
|
8
8
|
#
|
9
9
|
# In some cases the query will not support count. In that case, there are two ways to override the default behavior:
|
10
10
|
# - provide a count_query that can resolve the attributes
|
@@ -12,12 +12,16 @@ module NextPage
|
|
12
12
|
module PaginationAttributes
|
13
13
|
attr_writer :count_query, :current_page, :total_count, :per_page
|
14
14
|
|
15
|
+
def previous_page
|
16
|
+
current_page > 1 ? current_page - 1 : nil
|
17
|
+
end
|
18
|
+
|
15
19
|
def current_page
|
16
|
-
@current_page ||= count_query.offset_value + 1
|
20
|
+
@current_page ||= (count_query.offset_value || 0) + 1
|
17
21
|
end
|
18
22
|
|
19
23
|
def next_page
|
20
|
-
current_page + 1
|
24
|
+
total_pages > current_page ? current_page + 1 : nil
|
21
25
|
end
|
22
26
|
|
23
27
|
def total_count
|
data/lib/next_page/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: next_page
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Kummer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0
|
19
|
+
version: '6.0'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 6.0.2.2
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 6.0
|
29
|
+
version: '6.0'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 6.0.2.2
|