object_attorney 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/object_attorney/nested_objects.rb +7 -6
- data/lib/object_attorney/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTY5N2E4OTU1YTk3NzQ4MDkyNDZlNTQxN2I5OWNmZDI0YTZmNWEzZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzE0ODY2ZmRlNmE0MzM3NDc1YWI1N2MyMjIxNmNiNzFmODA2OTAxZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWJjMTkxYTU0MWU3NGM4YzFjZTg3ZDBmMDk1NDRmMWQzMzllNDBkYjI5N2Y5
|
10
|
+
MWRmMmRkOTE3NmFiNWRkMmUwODQ5ODg4OWVjOTY2NDYwODM1NzZjNjM2MzI3
|
11
|
+
MDg1NWQzZmRjYjQwNzc1OTM0ZTk2MzI0ZjdkMGZiODdiYjg3OTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTVjNjQ2NzNkZGZiMGVmMmE4Yzg5MzUxM2VlYWI3NzdkMmM0NTNmZDAyZmM4
|
14
|
+
YjY1ZGQ3NDljYTNhNWM2Mjc5ZjMyZWYwYWE4NWRlOTkzMmQ0Yzg1MWE4MTI4
|
15
|
+
YTA3ZTMwNTgyYjYxYjdmYmJjYzI5ZDljY2E3YTRiMDRmNTY1NGE=
|
@@ -115,7 +115,7 @@ module ObjectAttorney
|
|
115
115
|
attributes = send("#{nested_object_name}_attributes")
|
116
116
|
|
117
117
|
if nested_object.present?
|
118
|
-
return nested_object if (attributes["id"] || attributes[:id]).to_s != nested_object.id.to_s
|
118
|
+
#return nested_object if (attributes["id"] || attributes[:id]).to_s != nested_object.id.to_s
|
119
119
|
|
120
120
|
nested_object.assign_attributes(attributes_without_destroy(attributes))
|
121
121
|
mark_for_destruction_if_necessary(nested_object, attributes)
|
@@ -183,15 +183,16 @@ module ObjectAttorney
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def existing_nested_objects(nested_object_name)
|
186
|
-
|
186
|
+
nested_relection = self.class.reflect_on_association(nested_object_name)
|
187
187
|
|
188
|
-
|
188
|
+
existing = represented_object.blank? ? nested_relection.klass.all : represented_object.send(nested_object_name)
|
189
|
+
existing ||= (nested_relection.has_many? ? [] : nil)
|
189
190
|
|
190
|
-
if represented_object.present? &&
|
191
|
-
|
191
|
+
if represented_object.present? && nested_relection.klass != self.class.represented_object_class.reflect_on_association(nested_object_name).try(:klass)
|
192
|
+
existing = existing.map { |existing_nested_object| nested_relection.klass.new({}, existing_nested_object) }
|
192
193
|
end
|
193
194
|
|
194
|
-
|
195
|
+
existing
|
195
196
|
end
|
196
197
|
|
197
198
|
module ClassMethods
|