napa_pagination 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/napa_pagination/grape_helpers.rb +2 -1
- data/lib/napa_pagination/pagination.rb +8 -1
- data/lib/napa_pagination/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07d5307088369425a0b17541a94234c47451b619
|
4
|
+
data.tar.gz: 7c2069fcf395bbc9c4261abca4bc633b8a32af6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f03cb1064bf82e50b2460f23abeecd936e1c06fe344f38d13f9be5e6583d5e9941efc646e0ac1f9545b6a2180cf52fd400ea3d17364737266d8a3b35ad74199
|
7
|
+
data.tar.gz: df5563f6d04fa1849087082d4966bbae1408a7adf87721005b202de0870408218a554e1e756be24f6c64066c9152fe136f4a2f6213ec7879f1ddbb4010ca1780
|
@@ -5,8 +5,9 @@ module NapaPagination
|
|
5
5
|
|
6
6
|
if data.respond_to?(:to_a)
|
7
7
|
return {}.tap do |r|
|
8
|
+
data = NapaPagination::Pagination.new(represent_pagination(data))
|
8
9
|
r[:data] = data.map{ |item| with.new(item).to_hash(args) }
|
9
|
-
r[:pagination] =
|
10
|
+
r[:pagination] = data.to_h
|
10
11
|
end
|
11
12
|
else
|
12
13
|
return { data: with.new(data).to_hash(args)}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module NapaPagination
|
2
2
|
class Pagination
|
3
|
+
include Enumerable
|
3
4
|
def initialize(object)
|
4
5
|
@object = object
|
5
6
|
end
|
@@ -16,5 +17,11 @@ module NapaPagination
|
|
16
17
|
p[:total_count] = @object.total_count if @object.respond_to?(:total_count)
|
17
18
|
end
|
18
19
|
end
|
20
|
+
|
21
|
+
def each(&block)
|
22
|
+
@object.each do |member|
|
23
|
+
block.call(member)
|
24
|
+
end
|
25
|
+
end
|
19
26
|
end
|
20
|
-
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: napa_pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darby Frey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|