restpack_serializer 0.4.15 → 0.4.16
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: edca97b0920315c164716fd440b31108e76c65f4
|
4
|
+
data.tar.gz: fba756395137ac36ec9c1e75d610050bb3fbe008
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07fa0719ed2576ee95a0d025edc215ee99375346b04b581603d167fd20eceeaca9ac42b9942a14cf245e2f733699325169169c3b3f8c799ae02a8c0c8b2e54b2
|
7
|
+
data.tar.gz: e4ef801153749be306c31fcdb6afff9caf194e18405be2f50d69c3efffb234542d5ac02df9e11be7e51d2c1a3a6ee3b5279713819556be086a80d51a586fd8f7
|
data/lib/restpack_serializer.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'will_paginate/active_record'
|
1
|
+
require 'kaminari'
|
3
2
|
require 'protected_attributes'
|
4
3
|
|
5
4
|
require 'restpack_serializer/version'
|
@@ -8,6 +7,8 @@ require 'restpack_serializer/serializable'
|
|
8
7
|
require 'restpack_serializer/factory'
|
9
8
|
require 'restpack_serializer/result'
|
10
9
|
|
10
|
+
Kaminari::Hooks.init
|
11
|
+
|
11
12
|
module RestPack
|
12
13
|
module Serializer
|
13
14
|
mattr_accessor :config
|
@@ -7,10 +7,7 @@ module RestPack::Serializer::Paging
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def page_with_options(options)
|
10
|
-
page = options.scope_with_filters.
|
11
|
-
page: options.page,
|
12
|
-
per_page: options.page_size
|
13
|
-
)
|
10
|
+
page = options.scope_with_filters.page(options.page).per(options.page_size)
|
14
11
|
|
15
12
|
result = RestPack::Serializer::Result.new
|
16
13
|
result.resources[self.key] = serialize_page(page, options)
|
@@ -39,11 +36,11 @@ module RestPack::Serializer::Paging
|
|
39
36
|
meta = {
|
40
37
|
page: options.page,
|
41
38
|
page_size: options.page_size,
|
42
|
-
count: page.
|
39
|
+
count: page.total_count,
|
43
40
|
include: options.include
|
44
41
|
}
|
45
42
|
|
46
|
-
meta[:page_count] = ((page.
|
43
|
+
meta[:page_count] = ((page.total_count - 1) / options.page_size) + 1
|
47
44
|
meta[:previous_page] = meta[:page] > 1 ? meta[:page] - 1 : nil
|
48
45
|
meta[:next_page] = meta[:page] < meta[:page_count] ? meta[:page] + 1 : nil
|
49
46
|
|
data/restpack_serializer.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency 'activerecord', '~> 4.0.3'
|
21
21
|
gem.add_dependency 'activesupport', '~> 4.0.3'
|
22
22
|
gem.add_dependency 'protected_attributes', '~> 1.0.5'
|
23
|
-
gem.add_dependency '
|
23
|
+
gem.add_dependency 'kaminari', '~> 0.15.1'
|
24
24
|
|
25
25
|
gem.add_development_dependency 'restpack_gem', '~> 0.0.9'
|
26
26
|
gem.add_development_dependency 'rake', '~> 10.0.3'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.0.5
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: kaminari
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.15.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.15.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: restpack_gem
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|