clashinator 1.0 → 1.1
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/clashinator/array_resource.rb +8 -12
- data/lib/clashinator/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: e7b7ad615075eb6142f8eb9c18ae20e246142205
|
4
|
+
data.tar.gz: 9e1e8c5d821903f2fbe100c1658089cd5d9752eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e291d702bcca0d24ce2f1389f21e64e45e4d30892bc35f1e8da77469c7cf790911caa1a2cd5794d90236ef41fd416d6825979b2e430ec095ae3c0dd23048d09
|
7
|
+
data.tar.gz: 2138b2d895f23b689e93bc9a42f20392b73a9ed4f44ba90dd84edcf35b4139c46d066a03c84bce1618d9e9641f4ae921e7f0b5f076d9b93ab6e0f1a42fb7415b
|
@@ -6,14 +6,12 @@ module Clashinator
|
|
6
6
|
class ArrayResource
|
7
7
|
attr_accessor :items, :paging, :model
|
8
8
|
|
9
|
-
def initialize(model, items, paging = {})
|
10
|
-
# if after and before are equal, it means it's end of pagination
|
9
|
+
def initialize(model, items, paging = { 'cursors' => {} })
|
11
10
|
@model = model
|
12
11
|
@items = as_array_of_model(items)
|
13
12
|
@paging = Clashinator::ArrayResource::Cursor.new(
|
14
|
-
paging['cursors']
|
15
|
-
|
16
|
-
) if paging.key?('cursors')
|
13
|
+
paging['cursors']
|
14
|
+
)
|
17
15
|
end
|
18
16
|
|
19
17
|
private def as_array_of_model(array)
|
@@ -27,16 +25,14 @@ module Clashinator
|
|
27
25
|
end
|
28
26
|
|
29
27
|
# This class represent the cursor model
|
30
|
-
# that contains an after
|
31
|
-
# for properly paging array resources
|
28
|
+
# that contains an after attribute, a before attribute
|
29
|
+
# or neither, for properly paging array resources
|
32
30
|
class Cursor
|
33
31
|
attr_accessor :after, :before
|
34
32
|
|
35
|
-
def initialize(
|
36
|
-
|
37
|
-
|
38
|
-
@after = after
|
39
|
-
@before = before
|
33
|
+
def initialize(cursor_hash)
|
34
|
+
@after = cursor_hash['after'] if cursor_hash.key?('after')
|
35
|
+
@before = cursor_hash['before'] if cursor_hash.key?('before')
|
40
36
|
end
|
41
37
|
end
|
42
38
|
end
|
data/lib/clashinator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clashinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Cabeza
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|