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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzI5NzFiNmZiYjNhMzg3MWU2ZjQ4MzI5M2Q0ODI2ODczM2M1YjFmOA==
4
+ OTY5N2E4OTU1YTk3NzQ4MDkyNDZlNTQxN2I5OWNmZDI0YTZmNWEzZg==
5
5
  data.tar.gz: !binary |-
6
- NTdjMWMyMWM3YjYyZWFhOTc2ZjlkNjMyZTJhMTViYjZmNjgzMmNhOA==
6
+ YzE0ODY2ZmRlNmE0MzM3NDc1YWI1N2MyMjIxNmNiNzFmODA2OTAxZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTVhMmJjZmViNDU2ZjNkYWNhMjI0MDI4ZWMwODdlMDdhYjEzOWEwZDkzNzJh
10
- ZTc5Nzg5NDE3ZGVjNTM4MmExOGE5MmRkYWE0NGUyM2E4ZDNkM2ZhNDM3ZGZj
11
- NTU2NDJmNWZiM2Q1ZmU0YTY2OThkNTRhZjBlMDkzOGE0ODMwYmU=
9
+ MWJjMTkxYTU0MWU3NGM4YzFjZTg3ZDBmMDk1NDRmMWQzMzllNDBkYjI5N2Y5
10
+ MWRmMmRkOTE3NmFiNWRkMmUwODQ5ODg4OWVjOTY2NDYwODM1NzZjNjM2MzI3
11
+ MDg1NWQzZmRjYjQwNzc1OTM0ZTk2MzI0ZjdkMGZiODdiYjg3OTQ=
12
12
  data.tar.gz: !binary |-
13
- ODgyOTE4YzgyNTA5NDliYjlhOWY0MzA0NWEwZGExOGY0ZWNmNjUwZGEzMWM4
14
- Y2M5NzI4YjZmOTMwZWUzOTVhMDUzNGZjN2QxM2ExOTdjM2U1MzAyZTllZjVh
15
- Y2NmNTI3YWM0YjhkZjgxZmUyOTcxZTQxYjAyZWJkMDQ1ZWY3OGQ=
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
- nested_association_klass = self.class.reflect_on_association(nested_object_name).klass
186
+ nested_relection = self.class.reflect_on_association(nested_object_name)
187
187
 
188
- existing_list = represented_object.blank? ? nested_association_klass.all : (represented_object.send(nested_object_name) || [])
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? && nested_association_klass != self.class.represented_object_class.reflect_on_association(nested_object_name).try(:klass)
191
- existing_list = existing_list.map { |existing_nested_object| nested_association_klass.new({}, existing_nested_object) }
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
- existing_list
195
+ existing
195
196
  end
196
197
 
197
198
  module ClassMethods
@@ -1,3 +1,3 @@
1
1
  module ObjectAttorney
2
- VERSION = "2.2.3"
2
+ VERSION = "2.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_attorney
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves