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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3817c5eb61324763c5381d8c08028a084582990d
4
- data.tar.gz: 1159861050a883d131a3900b4b214ef0ed52eb27
3
+ metadata.gz: '043921a30ecb1c68470cf1cc6e889095b431bbb1'
4
+ data.tar.gz: 1804468d3679aeef8f43f23202e4c76f9f05d4e5
5
5
  SHA512:
6
- metadata.gz: 3ff6ca0dd9db8aac5b84ca500264131a28845b8b01daa3789c6fd0574ff47d26412784173ba553fa3d5d506e2e7082999a4c61a0c99bd3130cecccbf00a0f392
7
- data.tar.gz: a93ea8aff07090144b646fbdd173521fbaff553d894374a0e2a14cebb9cdd833a4a288223a7271559c37833ff3bc5df31734b94dcbfbd344d840b6e3a1354ed7
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", '>= 1.0.beta.3'
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.0.beta.11"
2
+ VERSION = "1.0.beta.12"
3
3
  end
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.11
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-02 00:00:00.000000000 Z
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.3
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.3
212
+ version: 1.0.beta.4
213
213
  description:
214
214
  email:
215
215
  - richmolj@gmail.com