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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc0a222313043518cba95ab5cba8b04ba260a1668d570cae3f8e0450458d8773
4
- data.tar.gz: 1e865c0c7de475e1edb754957db1ab6d4f72e863dc9baa995c90c27c8006ca99
3
+ metadata.gz: 48258d40caac39b331bba8d81ea99fcbb5523bab818616243149a952c4c286ea
4
+ data.tar.gz: b52465382e154b636c18f1b0c881cc3c5a4908aa4410a959fe4696904764846b
5
5
  SHA512:
6
- metadata.gz: 4111d99ac3cca85231988f6dd665c9091416b3a9ad7b29dea0108dc8cd4617cdb38c0f3068d64586741365d463b1c3ea390f28b58199b1ea20fbc7098cf5192d
7
- data.tar.gz: 80c2bcbdaa84c8ef48a1f680df6a56fa1607d097b01546c9f553983fd5c4fa171a031abcafc122591576b7b0c2304df65acab3e89cd92ad8e5faabc6d7fe0862
6
+ metadata.gz: ecdb889ce15846cda3025f6d8c07f61e2901c7633e191c88b8c9aedea79105fd639d95e9abbed8f1cfed8be98ab885f7be4cd67cf5d87d451812e93cceb929b6
7
+ data.tar.gz: 3a1aea4f5ca07e1656e61bc89a4cae38cfb0fe9523d26a7fb5a3064661e87c06c1c1f811fd3191b5f262b5186eabf38e3a40414064d4c1d3eb5bd56d10bb7704
@@ -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
- options = args.first
75
- return super unless options.is_a?(Hash) && options.key?(:json)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module NextPage
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
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.5
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-06-14 00:00:00.000000000 Z
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: []