graphiti 1.0.beta.11 → 1.0.beta.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/graphiti.gemspec +1 -1
- data/lib/graphiti/configuration.rb +10 -0
- data/lib/graphiti/serializer.rb +21 -0
- data/lib/graphiti/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '043921a30ecb1c68470cf1cc6e889095b431bbb1'
|
4
|
+
data.tar.gz: 1804468d3679aeef8f43f23202e4c76f9f05d4e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c60f1bf7e34464d7f669d36f9832f5c421687b4e0da3a5cb1d3bb4e3dd02cad72af994b6998531fdf6081519627dc551ba0ecac4edd4676b89dfa54562e86c3
|
7
|
+
data.tar.gz: 247a3fc07599f2674153fc62b35f7cb8084d0b154a0254a0e7287bb322f62a5e4deace96bacd71007f5cba931a8c31ee2a0feefe91463c6fcce6cac087fcb15e
|
data/graphiti.gemspec
CHANGED
@@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency "sqlite3"
|
33
33
|
spec.add_development_dependency "database_cleaner"
|
34
34
|
spec.add_development_dependency "activemodel", ['>= 4.1', '< 6']
|
35
|
-
spec.add_development_dependency "graphiti_spec_helpers", '
|
35
|
+
spec.add_development_dependency "graphiti_spec_helpers", '1.0.beta.4'
|
36
36
|
end
|
@@ -47,5 +47,15 @@ module Graphiti
|
|
47
47
|
@debug_models = val
|
48
48
|
Debugger.debug_models = val
|
49
49
|
end
|
50
|
+
|
51
|
+
def with_option(key, value)
|
52
|
+
begin
|
53
|
+
original = send(key)
|
54
|
+
send(:"#{key}=", value)
|
55
|
+
yield
|
56
|
+
ensure
|
57
|
+
send(:"#{key}=", original)
|
58
|
+
end
|
59
|
+
end
|
50
60
|
end
|
51
61
|
end
|
data/lib/graphiti/serializer.rb
CHANGED
@@ -22,6 +22,12 @@ module Graphiti
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def as_jsonapi(*)
|
26
|
+
super.tap do |hash|
|
27
|
+
strip_relationships!(hash) if strip_relationships?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
25
31
|
# Temporary fix until fixed upstream
|
26
32
|
# https://github.com/jsonapi-rb/jsonapi-serializable/pull/102
|
27
33
|
def requested_relationships(fields)
|
@@ -36,5 +42,20 @@ module Graphiti
|
|
36
42
|
super
|
37
43
|
end
|
38
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def strip_relationships!(hash)
|
49
|
+
hash[:relationships].select! do |name, payload|
|
50
|
+
payload.has_key?(:data)
|
51
|
+
end
|
52
|
+
hash.delete(:relationships) if hash[:relationships].empty?
|
53
|
+
end
|
54
|
+
|
55
|
+
def strip_relationships?
|
56
|
+
return false unless Graphiti.config.links_on_demand
|
57
|
+
params = Graphiti.context[:object].params || {}
|
58
|
+
[false, nil, 'false'].include?(params[:links])
|
59
|
+
end
|
39
60
|
end
|
40
61
|
end
|
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.0.beta.
|
4
|
+
version: 1.0.beta.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|
@@ -200,16 +200,16 @@ dependencies:
|
|
200
200
|
name: graphiti_spec_helpers
|
201
201
|
requirement: !ruby/object:Gem::Requirement
|
202
202
|
requirements:
|
203
|
-
- -
|
203
|
+
- - '='
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version: 1.0.beta.
|
205
|
+
version: 1.0.beta.4
|
206
206
|
type: :development
|
207
207
|
prerelease: false
|
208
208
|
version_requirements: !ruby/object:Gem::Requirement
|
209
209
|
requirements:
|
210
|
-
- -
|
210
|
+
- - '='
|
211
211
|
- !ruby/object:Gem::Version
|
212
|
-
version: 1.0.beta.
|
212
|
+
version: 1.0.beta.4
|
213
213
|
description:
|
214
214
|
email:
|
215
215
|
- richmolj@gmail.com
|