graphiti 1.2.11 → 1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/graphiti/resource/sideloading.rb +14 -0
- data/lib/graphiti/sideload.rb +4 -0
- data/lib/graphiti/util/persistence.rb +2 -2
- data/lib/graphiti/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 345a2d39445d433019a8c0055cf337b4b8fdf21e9d59e5785b923a5ee1a8c9fb
|
4
|
+
data.tar.gz: 0ec15af245b2c7bb9530e9b771839eb6b4487d3ca87cadb9b41788ce8cc63326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25dffc875c9f781f29467940e320888ba53fc974964c6267018d49eb9bc7cc274819fb46209f31a13bd1747b7cffcbd87542fb675e624c3491196a9dd255292d
|
7
|
+
data.tar.gz: 656c3ba8365f422d119b8df8d1ac6a2f4a23a2f57b460d1e18356b6bdfac938059397082df5665ee8b890dcc61868173e328976955204a7bd511bd3b410a2844
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Stylish Graph APIs.
|
|
12
12
|
|
13
13
|
[Website](https://www.graphiti.dev/guides/)
|
14
14
|
|
15
|
-
[Join the Slack Channel](https://join.slack.com/t/graphiti-api/shared_invite/
|
15
|
+
[Join the Slack Channel](https://join.slack.com/t/graphiti-api/shared_invite/enQtMjkyMTA3MDgxNTQzLTU5MDI4MDllNTEzOTE1Nzk0ZGJlNTcxZDYzMGY2ZTczMDY2OWZhM2RmNTU0YWNiOWZhZDhkMmU4MzQ5NzIyNWM)
|
16
16
|
|
17
17
|
Direct Contact: richmolj@gmail.com
|
18
18
|
|
@@ -75,6 +75,20 @@ module Graphiti
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
def polymorphic_has_one(name, opts = {}, &blk)
|
79
|
+
as = opts.delete(:as)
|
80
|
+
opts[:foreign_key] ||= :"#{as}_id"
|
81
|
+
opts[:polymorphic_as] ||= as
|
82
|
+
model_ref = model
|
83
|
+
has_one name, opts do
|
84
|
+
params do |hash|
|
85
|
+
hash[:filter][:"#{as}_type"] = model_ref.name
|
86
|
+
end
|
87
|
+
|
88
|
+
instance_eval(&blk) if block_given?
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
78
92
|
def sideload(name)
|
79
93
|
sideloads[name]
|
80
94
|
end
|
data/lib/graphiti/sideload.rb
CHANGED
@@ -83,13 +83,13 @@ class Graphiti::Util::Persistence
|
|
83
83
|
return if x[:sideload].type == :many_to_many
|
84
84
|
|
85
85
|
if [:destroy, :disassociate].include?(x[:meta][:method])
|
86
|
-
if x[:sideload].polymorphic_has_many?
|
86
|
+
if x[:sideload].polymorphic_has_one? || x[:sideload].polymorphic_has_many?
|
87
87
|
attrs[:"#{x[:sideload].polymorphic_as}_type"] = nil
|
88
88
|
end
|
89
89
|
attrs[x[:foreign_key]] = nil
|
90
90
|
update_foreign_type(attrs, x, null: true) if x[:is_polymorphic]
|
91
91
|
else
|
92
|
-
if x[:sideload].polymorphic_has_many?
|
92
|
+
if x[:sideload].polymorphic_has_one? || x[:sideload].polymorphic_has_many?
|
93
93
|
attrs[:"#{x[:sideload].polymorphic_as}_type"] = parent_object.class.name
|
94
94
|
end
|
95
95
|
attrs[x[:foreign_key]] = parent_object.send(x[:primary_key])
|
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.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: 2019-
|
11
|
+
date: 2019-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|