active_model_serializers_contrib 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70f7d6ef1d380cc286dea11ef8d61796e4bb67f6
|
4
|
+
data.tar.gz: dd4e99c972c9ff6952a816c1c650ff562fa6f2ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23705fe6aef66f71de558aaf67e1eaebb9605356f6337854e2e66b33f7524f1207beacc1a89cea0be529c35220245ac6b7f4923f15c5c0490520e5fa9d0a2a11
|
7
|
+
data.tar.gz: efcea6ad9a11ae7c9dbe9ba34fa295da3bfdf8a7b2e2a7e7e5444324997b8acfa2975324f6019608cbf3101f3cf25df9bce65958402edb95daf2ffd42fb79edb
|
@@ -4,8 +4,8 @@ class ActiveModel::PaginationSerializer < ActiveModel::ArraySerializer
|
|
4
4
|
per_page = object.limit_value
|
5
5
|
offset = object.offset_value
|
6
6
|
current_page = offset ? (offset / per_page) + 1 : 1
|
7
|
-
|
8
|
-
total_pages = per_page ? (
|
7
|
+
total_items = object.limit(nil).offset(nil).count
|
8
|
+
total_pages = per_page ? (total_items / per_page).ceil : 1
|
9
9
|
prev_page = current_page - 1
|
10
10
|
prev_page = nil if prev_page < 1
|
11
11
|
next_page = current_page + 1
|
@@ -14,7 +14,7 @@ class ActiveModel::PaginationSerializer < ActiveModel::ArraySerializer
|
|
14
14
|
opts[:meta] ||= {}
|
15
15
|
opts[:meta][:current_page] = current_page
|
16
16
|
opts[:meta][:total_pages] = total_pages
|
17
|
-
opts[:meta][:
|
17
|
+
opts[:meta][:total_items] = total_items
|
18
18
|
opts[:meta][:prev_page] = prev_page
|
19
19
|
opts[:meta][:next_page] = next_page
|
20
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_model_serializers_contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- G5
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active_model_serializers
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
requirements: []
|
160
160
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.4.
|
161
|
+
rubygems_version: 2.4.3
|
162
162
|
signing_key:
|
163
163
|
specification_version: 4
|
164
164
|
summary: Modules/classes that extend AMS with more functionality
|