graphiti 1.2.17 → 1.2.18
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f286647b00c9b97ec5c280e48e4758f31fbee7f00e19d22073b95c8f10956ad6
|
4
|
+
data.tar.gz: bf208a2b4971f7603bf287c2cfe4787b36525a8b6612e62a99b3bacd7cd80b45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1af7ee296afbe6cf900ceb6e3c7fd4e05fd8b0df81d91b748d2b970fdf77245298e755c024c150cde26e86636c3814a20ab45934b810af8ed501b2ec43449549
|
7
|
+
data.tar.gz: f51c1183ede1fd0e4e5aa91ec145b3cd1bc5f7e4633cd61e59232fc6575cb39ca85240fa8590d5b264b29b0522352888b6a7c684cd48a7f4e46b5e47a692155e
|
@@ -20,13 +20,17 @@ module Graphiti
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
def pagination_params
|
24
|
+
@pagination_params ||= @proxy.query.params.reject { |key, _| [:action, :controller, :format].include?(key) }
|
25
|
+
end
|
26
|
+
|
23
27
|
def pagination_link(page)
|
24
28
|
return nil unless @proxy.resource.endpoint
|
25
29
|
|
26
30
|
uri = URI(@proxy.resource.endpoint[:url].to_s)
|
27
31
|
|
28
32
|
# Overwrite the pagination query params with the desired page
|
29
|
-
uri.query =
|
33
|
+
uri.query = pagination_params.merge({
|
30
34
|
page: {
|
31
35
|
number: page,
|
32
36
|
size: page_size
|
data/lib/graphiti/resource.rb
CHANGED
@@ -148,5 +148,15 @@ module Graphiti
|
|
148
148
|
end
|
149
149
|
response
|
150
150
|
end
|
151
|
+
|
152
|
+
def links?
|
153
|
+
self.class.links.any?
|
154
|
+
end
|
155
|
+
|
156
|
+
def links(model)
|
157
|
+
self.class.links.each_with_object({}) do |(name, blk), memo|
|
158
|
+
memo[name] = instance_exec(model, &blk)
|
159
|
+
end
|
160
|
+
end
|
151
161
|
end
|
152
162
|
end
|
@@ -199,7 +199,8 @@ module Graphiti
|
|
199
199
|
attributes: {},
|
200
200
|
extra_attributes: {},
|
201
201
|
sideloads: {},
|
202
|
-
callbacks: {}
|
202
|
+
callbacks: {},
|
203
|
+
links: {}
|
203
204
|
}
|
204
205
|
end
|
205
206
|
|
@@ -238,6 +239,10 @@ module Graphiti
|
|
238
239
|
def default_filters
|
239
240
|
config[:default_filters]
|
240
241
|
end
|
242
|
+
|
243
|
+
def links
|
244
|
+
config[:links]
|
245
|
+
end
|
241
246
|
end
|
242
247
|
|
243
248
|
def get_attr!(name, flag, options = {})
|
data/lib/graphiti/serializer.rb
CHANGED
@@ -25,6 +25,7 @@ module Graphiti
|
|
25
25
|
def as_jsonapi(*)
|
26
26
|
super.tap do |hash|
|
27
27
|
strip_relationships!(hash) if strip_relationships?
|
28
|
+
add_links!(hash)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -49,6 +50,12 @@ module Graphiti
|
|
49
50
|
|
50
51
|
private
|
51
52
|
|
53
|
+
def add_links!(hash)
|
54
|
+
return unless @resource.respond_to?(:links?)
|
55
|
+
|
56
|
+
hash[:links] = @resource.links(@object) if @resource.links?
|
57
|
+
end
|
58
|
+
|
52
59
|
def strip_relationships!(hash)
|
53
60
|
hash[:relationships]&.select! do |name, payload|
|
54
61
|
payload.key?(:data)
|
data/lib/graphiti/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|