object_attorney 2.10.1 → 2.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/object_attorney/nested_objects.rb +7 -3
- data/lib/object_attorney/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Mzg5Y2Q0NjA0NGIzMGUzY2ZjZjc0NTYxNzQyODAxMWQzMTE3NDIxNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzg3ZDI0N2JjNmYxMTMzZDMzOTc3NzQxNzNmNmRmMzk4ZGQxOWY5Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGU4ZGQ1MjEzYmNiYTUxYjMyZjIyN2Q4ZWZkYzcyZDYwNTAxNjczNjc0NTRk
|
10
|
+
YzQ3M2Y1OTA1MTVmOWFiZmRhNmYwMTZlNDA1MDg4YTU1OWNhODA1MTUxOTM1
|
11
|
+
MGViNzZkNWE4NTU5MzU0MDc4YjQzMjg4MjZmMDhjYjQwNzhiMmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2U4MGJkZTc4YjU3NmFlZTU3N2UyZDg4ZjE0OWZjMTM0YTE3ZGZiMjBkOTBk
|
14
|
+
MzM2NzE5M2Y3OTExNzYzYzA3MGE3YzI2ZTNlMDEwOTcwNWUwNzcyZDNkODNi
|
15
|
+
NjlhMTQ2Y2Y2YjgyNDNjZTA5NzQyZmFhMWExNjY1ZTNiODE5MzU=
|
@@ -155,14 +155,18 @@ module ObjectAttorney
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
def build_nested_object(nested_object_name, attributes = {})
|
158
|
+
def build_nested_object(nested_object_name, attributes = {}, new_nested_object = nil)
|
159
159
|
attributes = attributes.symbolize_keys
|
160
160
|
reflection = self.class.reflect_on_association(nested_object_name)
|
161
161
|
|
162
162
|
return nil if reflection.options[:new_records] == false
|
163
163
|
|
164
|
-
if
|
164
|
+
if new_nested_object.present?
|
165
|
+
new_nested_object = assign_attributes_or_build_nested_object(reflection, attributes, new_nested_object)
|
166
|
+
|
167
|
+
elsif reflection.options[:standalone] == true || !can_represented_object_build_nested?(reflection, nested_object_name)
|
165
168
|
new_nested_object = reflection.klass.new(attributes)
|
169
|
+
|
166
170
|
else
|
167
171
|
new_nested_object = build_from_represented_object(reflection, nested_object_name)
|
168
172
|
|
@@ -255,7 +259,7 @@ module ObjectAttorney
|
|
255
259
|
self.send(:attr_accessor, "#{nested_object_name}_attributes".to_sym)
|
256
260
|
|
257
261
|
define_method(nested_object_name) { nested_getter(nested_object_name) }
|
258
|
-
define_method("build_#{reflection.single_name}") { |attributes = {}, nested_object = nil| build_nested_object(nested_object_name, attributes) }
|
262
|
+
define_method("build_#{reflection.single_name}") { |attributes = {}, nested_object = nil| build_nested_object(nested_object_name, attributes, nested_object) }
|
259
263
|
define_method("existing_#{nested_object_name}") { existing_nested_objects(nested_object_name) }
|
260
264
|
end
|
261
265
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object_attorney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- João Gonçalves
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|