jsonapi_compliable 0.10.1 → 0.10.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 683efd67df594517b01f5b4d42ac9ec7763c8b43
|
4
|
+
data.tar.gz: dbdb64eb9a35dd750cb3baaa64bd6d43140126fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ecc62dc5d64239da53005213e9e28fc846580e377264ffbaef7beb6a5e945d5a67132cd1c64c01eafec3187ed7d81cd8287e312059bb7f439078c9456f38c0f
|
7
|
+
data.tar.gz: 2c67bd4923faee105de161daea829162fa2ba48a49cbe1f17e18893c58e05a7baa13797ea704d0954d9e33417bb28065ca091bfff3e13e0bab48211116ae7c45
|
@@ -73,11 +73,14 @@ module JsonapiCompliable
|
|
73
73
|
# @see Adapters::Abstract#associate
|
74
74
|
def associate(parent, child, association_name, association_type)
|
75
75
|
if association_type == :has_many
|
76
|
-
parent
|
77
|
-
parent.association(association_name).add_to_target(child, :skip_callbacks)
|
76
|
+
associate_many(parent, child, association_name)
|
78
77
|
elsif association_type == :habtm
|
79
|
-
parent.send(association_name)
|
80
|
-
|
78
|
+
if parent.send(association_name).exists?(child.id)
|
79
|
+
associate_many(parent, child, association_name)
|
80
|
+
else
|
81
|
+
parent.send(association_name) << child
|
82
|
+
end
|
83
|
+
elsif
|
81
84
|
child.send("#{association_name}=", parent)
|
82
85
|
end
|
83
86
|
end
|
@@ -113,6 +116,13 @@ module JsonapiCompliable
|
|
113
116
|
instance.destroy
|
114
117
|
instance
|
115
118
|
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
def associate_many(parent, child, association_name)
|
123
|
+
parent.association(association_name).loaded!
|
124
|
+
parent.association(association_name).add_to_target(child, :skip_callbacks)
|
125
|
+
end
|
116
126
|
end
|
117
127
|
end
|
118
128
|
end
|
@@ -95,13 +95,14 @@ class JsonapiCompliable::Util::Persistence
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def associate_children(object, children)
|
98
|
-
# No need to associate destroyed objects
|
99
|
-
return if @meta[:method] == :destroy
|
100
|
-
|
101
98
|
children.each do |x|
|
102
99
|
if x[:object] && object
|
103
100
|
if x[:meta][:method] == :disassociate
|
104
101
|
x[:sideload].disassociate(object, x[:object])
|
102
|
+
elsif x[:meta][:method] == :destroy
|
103
|
+
if x[:sideload].type == :habtm
|
104
|
+
x[:sideload].disassociate(object, x[:object])
|
105
|
+
end # otherwise, no need to disassociate destroyed objects
|
105
106
|
else
|
106
107
|
x[:sideload].associate(object, x[:object])
|
107
108
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi_compliable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-10-
|
12
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|