next_page 0.1.5 → 0.1.6
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/lib/next_page/pagination.rb +3 -5
- data/lib/next_page/paginator.rb +8 -0
- data/lib/next_page/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 48258d40caac39b331bba8d81ea99fcbb5523bab818616243149a952c4c286ea
|
|
4
|
+
data.tar.gz: b52465382e154b636c18f1b0c881cc3c5a4908aa4410a959fe4696904764846b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ecdb889ce15846cda3025f6d8c07f61e2901c7633e191c88b8c9aedea79105fd639d95e9abbed8f1cfed8be98ab885f7be4cd67cf5d87d451812e93cceb929b6
|
|
7
|
+
data.tar.gz: 3a1aea4f5ca07e1656e61bc89a4cae38cfb0fe9523d26a7fb5a3064661e87c06c1c1f811fd3191b5f262b5186eabf38e3a40414064d4c1d3eb5bd56d10bb7704
|
data/lib/next_page/pagination.rb
CHANGED
|
@@ -71,11 +71,9 @@ module NextPage
|
|
|
71
71
|
def render(*args) #:nodoc:
|
|
72
72
|
return super unless action_name == 'index' && request.headers[:Accept] == 'application/vnd.api+json'
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
options[:meta] = options.fetch(:meta, {}).merge!(total_pages: options[:json].total_pages,
|
|
78
|
-
total_count: options[:json].total_count)
|
|
74
|
+
self.class.next_page_paginator.decorate_meta!(args.first)
|
|
75
|
+
super
|
|
76
|
+
rescue StandardError
|
|
79
77
|
super
|
|
80
78
|
end
|
|
81
79
|
end
|
data/lib/next_page/paginator.rb
CHANGED
|
@@ -43,6 +43,14 @@ module NextPage
|
|
|
43
43
|
data.limit(data.per_page).offset((data.current_page - 1) * data.per_page)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
def decorate_meta!(options)
|
|
47
|
+
return unless options.is_a?(Hash) && options.key?(:json) && !options[:json].is_a?(Hash)
|
|
48
|
+
|
|
49
|
+
resource = options[:json]
|
|
50
|
+
options[:meta] = options.fetch(:meta, {}).merge!(total_pages: resource.total_pages,
|
|
51
|
+
total_count: resource.total_count)
|
|
52
|
+
end
|
|
53
|
+
|
|
46
54
|
private
|
|
47
55
|
|
|
48
56
|
def model_class
|
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.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Todd Kummer
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -153,7 +153,7 @@ homepage: https://github.com/RockSolt/next_page
|
|
|
153
153
|
licenses:
|
|
154
154
|
- MIT
|
|
155
155
|
metadata: {}
|
|
156
|
-
post_install_message:
|
|
156
|
+
post_install_message:
|
|
157
157
|
rdoc_options: []
|
|
158
158
|
require_paths:
|
|
159
159
|
- lib
|
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
169
169
|
version: '0'
|
|
170
170
|
requirements: []
|
|
171
171
|
rubygems_version: 3.0.8
|
|
172
|
-
signing_key:
|
|
172
|
+
signing_key:
|
|
173
173
|
specification_version: 4
|
|
174
174
|
summary: Pagination for Rails Controllers
|
|
175
175
|
test_files: []
|